SQL Join
Join clause is used to mege data from two or more table into one table, using shared column between the two tables.
Types of Join
- Inner Join
- Left Join
- Right Join
- Full Join
- Cross Join
- Anti Left Join
- Anti Right Join
Products Table
Orders Table
Inner Join
retrieve rows that exist on both table only and exclude other rows
SELECT p.product_id,p.product_name,o.order_id
FROM products p
INNER JOIN orders o
ON (p.product_id=o.product_id)
Left Outer Join
Left outer join retrieves all rows from the left table and the matched rows only from the right table. Taking the products and orders tables above
Right Outer Join
Right outer join retrieves all rows from the right table and the matched rows only from the left table. Taking the products and orders tables above.
0 Comments