You are on page 1of 4

JOINS

Joins are used to query the date from more than 2 tables based on the
relation between them.
Can we store the data in one Table?
Yes we can, but its not a good database design.

Types of Joins

Inner Join
Left Join Left Outer Join
Right Join Right Outer Join
Full Join

Select all records from Table A and Table B, where the join condition is met.

SELECT
sales.sales_date,sales.order_id,sales.product_id,product.product_name
FROM sales INNER JOIN product
On Sales.product_id=product.product_id

Select all records from Table A, along with records from Table B for which the
join condition is met (if at all).

Select all records from Table B, along with records from Table A for which the
join condition is met (if at all).

Select all records from Table A and Table B, regardless of whether the join
condition is met or not.

Cross Join or CARTESIAN JOIN


CROSS JOIN will return all records where each row from the first table is
combined with each row from the second table. Which also mean CROSS
JOIN returns the Cartesian product of the sets of rows from the joined tables.

You might also like