A JOIN
clause is used to combine rows from two or more tables, based on a related column between them.
Supported Types of Joins in MySQL
![]() | Returns records that have matching values in both tables |
![]() | Returns all records from the left table, and the matched records from the right table |
![]() | Returns all records from the right table, and the matched records from the left table |
![]() | Returns all records from both tables |
Inner JOIN
![](https://tracto.dev/wp-content/uploads/2022/12/img_innerjoin.gif)
SELECT columns
FROM table1
INNER JOIN table2
ON table1.column = table2.column;
![](https://tracto.dev/wp-content/uploads/2022/12/inner-join-example.png)
![](https://tracto.dev/wp-content/uploads/2022/12/inner-join-example-2.png)
Left Outer JOIN
![](https://tracto.dev/wp-content/uploads/2022/12/img_leftjoin.gif)
SELECT columns
FROM table1
LEFT [OUTER] JOIN table2
ON table1.column = table2.column;
![](https://tracto.dev/wp-content/uploads/2022/12/left-join-example.png)
Right Outer JOIN
![](https://tracto.dev/wp-content/uploads/2022/12/img_rightjoin.gif)
SELECT columns
FROM table1
RIGHT [OUTER] JOIN table2
ON table1.column = table2.column;
![](https://tracto.dev/wp-content/uploads/2022/12/right-join-example.png)
Cross JOIN
![](https://tracto.dev/wp-content/uploads/2022/12/img_crossjoin.png)
SELECT columns
FROM table_1
CROSS JOIN table_2;
Unlike the INNER JOIN
, LEFT JOIN
, and RIGHT JOIN
, the cross join clause does not have a join condition.