By : Dhirendra Chauhan
SQL Join
Join
A JOIN clause is used to combine rows
from two or more tables, based on a
related column between them.
Types of SQL JOINs
1. Equi- Join
2. Non-Equi- Join
3. Natural Join
4. Cross Join
5. Left Join
6. Right Join
7. Full Join
8. Self Join
Equi JOIN
EQUI JOIN performs a JOIN against equality or matching column(s)
values of the associated tables. An equal sign (=) is used as comparison
operator in the where clause to refer equality.
Syntax
SELECT column_list
FROM table1 , table2....
WHERE table1.column_name = table2.column_name;
Table-1 Table-2
2. SALARY
1.EMPLOYEE
Non-Equi JOIN
The NON EQUI JOIN uses comparison operator instead of the
equal sign like >, <, >=, <= along with conditions.
Syntax
SELECT column_list
FROM table1 , table2....
WHERE table1.column_name != table2.column_name;
Table-1 Table-2
2. SALARY
1.EMPLOYEE
Natural JOIN
The NON EQUI JOIN uses comparison operator instead of the
equal sign like >, <, >=, <= along with conditions.
Syntax
SELECT column_list
FROM table1 Natural Join table2;
2. SALARY
1.EMPLOYEE
CROSS JOIN
The CROSS JOIN clause returns the Cartesian product
of rows from the joined tables.
Syntax
SELECT *
FROM table1 CROSS JOIN table2;
2. SALARY
1.EMPLOYEE
INNER JOIN
Syntax:
SELECT column_name(s)
FROM table1
Inner JOIN table2
ON table1.column_name = table2.column_name;
The INNER JOIN keyword selects records that have
matching values in both tables.
2. SALARY
1.EMPLOYEE
LEFT JOIN
The LEFT JOIN keyword returns all records from the left table
(table1), and the matched records from the right table (table2).
The result is NULL from the right side, if there is no match.
Syntax
SELECT column_name(s)
FROM table1
Left JOIN table2
ON table1.column_name = table2.column_name;
Table-2
Table-1
2. SALARY
1.EMPLOYEE
RIGHT JOIN
The RIGHT JOIN keyword returns all records from the right table (table2),
and the matched records from the left table (table1). The result is NULL
from the left side, when there is no match.
Syntax:
SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name = table2.column_name;
Table-1 Table-2
1. SALARY 2.EMPLOYEE
FULL JOIN
MySQL does not support FULL JOIN, so you have to combine
JOIN, UNION and LEFT JOIN to get an equivalent.
SELF JOIN
“A self JOIN is a regular join, but the table is
joined with itself.”
Syntax:
SELECT column_name / *
FROM table1 t1, table1 t2
Where Condition;
T1 and T2 are different table aliases for the same table.
Table-1 Table-1
T1 T2
Alias
THANK
YOU

V19 join method-c

  • 1.
  • 2.
  • 3.
    Join A JOIN clauseis used to combine rows from two or more tables, based on a related column between them.
  • 4.
    Types of SQLJOINs 1. Equi- Join 2. Non-Equi- Join 3. Natural Join 4. Cross Join 5. Left Join 6. Right Join 7. Full Join 8. Self Join
  • 5.
    Equi JOIN EQUI JOINperforms a JOIN against equality or matching column(s) values of the associated tables. An equal sign (=) is used as comparison operator in the where clause to refer equality. Syntax SELECT column_list FROM table1 , table2.... WHERE table1.column_name = table2.column_name;
  • 6.
  • 7.
  • 8.
    Non-Equi JOIN The NONEQUI JOIN uses comparison operator instead of the equal sign like >, <, >=, <= along with conditions. Syntax SELECT column_list FROM table1 , table2.... WHERE table1.column_name != table2.column_name;
  • 9.
  • 10.
  • 11.
    Natural JOIN The NONEQUI JOIN uses comparison operator instead of the equal sign like >, <, >=, <= along with conditions. Syntax SELECT column_list FROM table1 Natural Join table2;
  • 12.
  • 13.
    CROSS JOIN The CROSSJOIN clause returns the Cartesian product of rows from the joined tables. Syntax SELECT * FROM table1 CROSS JOIN table2;
  • 14.
  • 15.
    INNER JOIN Syntax: SELECT column_name(s) FROMtable1 Inner JOIN table2 ON table1.column_name = table2.column_name; The INNER JOIN keyword selects records that have matching values in both tables.
  • 16.
  • 17.
    LEFT JOIN The LEFTJOIN keyword returns all records from the left table (table1), and the matched records from the right table (table2). The result is NULL from the right side, if there is no match. Syntax SELECT column_name(s) FROM table1 Left JOIN table2 ON table1.column_name = table2.column_name;
  • 18.
  • 19.
  • 20.
    RIGHT JOIN The RIGHTJOIN keyword returns all records from the right table (table2), and the matched records from the left table (table1). The result is NULL from the left side, when there is no match. Syntax: SELECT column_name(s) FROM table1 RIGHT JOIN table2 ON table1.column_name = table2.column_name;
  • 21.
  • 22.
  • 23.
    FULL JOIN MySQL doesnot support FULL JOIN, so you have to combine JOIN, UNION and LEFT JOIN to get an equivalent.
  • 24.
    SELF JOIN “A selfJOIN is a regular join, but the table is joined with itself.” Syntax: SELECT column_name / * FROM table1 t1, table1 t2 Where Condition; T1 and T2 are different table aliases for the same table.
  • 25.
  • 28.