SQL Joins Notes
SQL Joins Notes
1. INNER JOIN
Syntax:
SELECT columns
FROM table1
ON table1.column = table2.column;
Returns all rows from the left table and matched rows from the right table. Unmatched rows from the
Syntax:
SELECT columns
FROM table1
ON table1.column = table2.column;
Returns all rows from the right table and matched rows from the left table. Unmatched rows from the
Syntax:
SELECT columns
FROM table1
SQL Joins - Notes
ON table1.column = table2.column;
Returns all rows when there is a match in one of the tables. Unmatched rows will have NULLs.
Syntax:
SELECT columns
FROM table1
ON table1.column = table2.column;
5. CROSS JOIN
Returns the Cartesian product of two tables. Every row in the first table is combined with all rows in
Syntax:
SELECT columns
FROM table1
6. SELF JOIN
A self join is a regular join but the table is joined with itself.
Syntax:
WHERE condition;