JOIN clause combine rows from two or more tables, based on a common field between them.
There are five types of JOIN, defined by ANSI standard SQLโ
Sr. | JOIN TYPES | USAGE |
1 | INNER JOIN | Returns records that have matching values in both tables |
2 | LEFT OUTER JOIN | Returns all records from left table and matching records from right table |
3 | RIGHT OUTER JOIN | Returns all records from right table, and matching records from the left table |
4 | FULL OUTER JOIN | Returns all records when there is a match in either left or right table |
5 | CROSS JOIN | Returns combinations of each row of the first table with the each row from second table. |
TYPE OF JOINS IN SQL
Syntax for INNER JOIN,LEFT JOIN,RIGHT JOIN,FULL OUTER JOIN-
SELECT <column_name(s)>
FROM <table1>
[INNER JOIN|LEFT JOIN|RIGHT JOIN|FULL OUTER JOIN]<table2>
ON <table1.column_name=table2.column_name>
WHERE<condition>;
Syntax for CROSS JOIN-
SELECT <column_name(s)>
FROM <table1>
CROSS JOIN<table2>;
Leave a Reply