Join in Sql
There are
basically 5 types of join in sql
1.Inner join2.Right join
3.Left join
4.Full join
5.Self join
6.Cross join
Inner join : It select all rows from both matching table at least one. It means the two rows they have in common.
SELECT * FROM table1 INNER JOIN table2 ON table1.column_name = table2.column_name
Right Join:
It
select all rows from right table and matching rows from left table.
SELECT column_name(s)
FROM table1
RIGHT JOIN table2 ON table1.column_name = table2.column_name;
FROM table1
RIGHT JOIN table2 ON table1.column_name = table2.column_name;
Left Join It select all rows from left table and matching from right table.
SELECT column_name(s)
FROM table1
LEFT JOIN table2 ON table1.column_name = table2.column_name;
FROM table1
LEFT JOIN table2 ON table1.column_name = table2.column_name;
Full join It select all rows from both table. It means return all records when there is a match in either left (table1) or right (table2) table records.
SELECT column_name(s)
FROM table1
FULL OUTER JOIN table2 ON table1.column_name = table2.column_name;
FROM table1
FULL OUTER JOIN table2 ON table1.column_name = table2.column_name;
0 Comments