DEV Community

Cover image for SQL JOINS WITH EXAMPLES OF EACH
Frankline Kibet
Frankline Kibet

Posted on

SQL JOINS WITH EXAMPLES OF EACH

A join combines rows from two or more tables based on a related column between them. Instead of running separate queries and manually matching up results yourself, a join does that matching for you, in a single query
When working with databases, your data is often stored in more than one table. This is way join are important

*TYPES OF JOINS *

1.** Inner join**
This is a type of join that returns only the rows that have a match in both tables.
example

  1. Left jOIN

Returns all rows from the left table plus matching rows from the right table.

Where there's no match the right table's columns come back as null

3*_.Right join _*
Returns all rows from the right table plus matching rows from the left.

4._ Full outer join _

Return all row from all table.

I used it when when you need a complete view of the table example like in this scenario above I need to check the results table and the subject table to identify areas of improvement.

  1. _self join _

This is a practical
use of self join that really help be in my project. it let me pair each book with it author with ease.

Top comments (0)