The SQL Joins are mostly used to combine records from two or more tables in a database for getting data. A JOIN defined as combining fields from 2 tables.
There are several operators that can be used to join tables. The opertaors that are used such as =, <, >, <>, <=, >=, !=, BETWEEN, LIKE, and NOT.
The types of SQL JOINS are --->
1-INNER JOINS - In INNER JOIN, the SQL query compares each row of table with another row of another table by which it will find all pairs of rows which satisfy the join. After Satisfying it will show the result
For example->
SELECT table1.column1, table2.column2
FROM table1
INNER JOIN table2
ON table1.common_field = table2.common_field;
2-SQL - LEFT JOINS
Left join returns all the values from the left table with the matched values from the right table.
SELECT table1.column1, table2.column2
FROM table1
LEFT JOIN table2
ON table1.common_field = table2.common_field;
3-Right- Joins
Right join returns all the values from the right table with the matched values from the left table.
SELECT table1.column1, table2.column2
FROM table1
RIGHT JOIN table2
ON table1.common_field = table2.common_field;
4- SQL Full Join
The SQL FULL JOIN is a combination of left and right outer joins.
SELECT table1.column1, table2.column2...
FROM table1
FULL JOIN table2
ON table1.common_field = table2.common_field;
5-SQL - CARTESIAN
A Cartesian join is defined as a join , when we join each row of table to each row of another table.
We will get one table .
example
SELECT table1.column1, table2.column2
FROM table1, table2 [, table3 ]
0 Comment(s)