How To Join 2 Tables In SQL?

Use `INNER JOIN` to return rows with matching values in both tables

Use `LEFT JOIN` to return all rows from the left table and matching rows from the right table

Use `RIGHT JOIN` to return all rows from the right table and matching rows from the left table

Use `FULL OUTER JOIN` to return all rows from both tables, matching where possible

Use `CROSS JOIN` to return the Cartesian product of both tables

Use `JOIN … ON` to specify the join condition

Use `JOIN … USING(column_name)` when both tables share the same column name

Use table aliases to make queries shorter and clearer

Use matching key columns such as `id`, `customer_id`, or `order_id`

Use `SELECT` to choose columns from both tables

Example: `SELECT * FROM table1 INNER JOIN table2 ON table1.id = table2.id;`

Suggested for You

Trending Today