MYSQL JOINS:
Basically, JOINS are used to join two or more tables of the database.
Why JOINS?
-When we want to get some information which may contain by more than one table then we JOIN every table to get that information.
Is we Done our work with JOINS?
Yes, Without JOINS we also get information from multiple tables by nested Query.
Types of JOINS:
1. INNER JOIN:
-Return that record which match in both table.
Syntax:
SELECT columns FROM table1 INNER JOIN table2;
2. LEFT JOIN
-returns all rows from the left table, even if there are no matches in the right table.
Syntax:
SELECT columns FROM table1 LEFT JOIN table2;
3.RIGHT JOIN
-returns all rows from the right table, even if there are no matches in the left table.
Syntax:
SELECT columns FROM table1 RIGHT JOIN table2;
4. FULL JOIN
-returns rows when there is a match in one of the tables.
Syntax:
SELECT columns FROM table1 RIGHT JOIN table2;
5. SELF JOIN
-Join with own table is called as SELF JOIN.
Syntax:
SELECT columns FROM table1 SELF JOIN table1;
6. CARTESIAN JOIN
-Return all record from first and second table.
Synatx:
SELECT columns FROM table1 CARTESIAIN table1;