TYPES OF JOIN USED IN MYSQL
Definition: INNER JOIN
Returns rows where there is a match in both tables based on the common id.
SELECT * FROM employee INNER JOIN department ON employee.id
= department.id;
Definition: LEFT JOIN
Returns all rows from the "employee" table and matched rows from the "department" table. If there is no match, NULL values are returned for "department" columns.
SELECT * FROM employee LEFT JOIN department ON employee.id =
department.id;
Definition: RIGHT JOIN
Returns all rows from the "department" table and matched rows from the "employee" table. If there is no match, NULL values are returned for "employee" columns.
SELECT * FROM employee RIGHT JOIN department ON employee.id
= department.id;
Definition: FULL JOIN
Returns all rows when there is a match in either "employee" or "department" table. If there is no match, NULL values are returned for columns from the table without a match.
SELECT * FROM employee FULL JOIN department ON employee.id =
department.id;
Definition: CROSS JOIN
Returns all the records of "employee" and "department" tables, i.e., all possible combinations.
SELECT * FROM employee CROSS JOIN department;
Comments
Post a Comment