A join is an operation in SQL that combines rows from two or more tables based on a related column.
Explanation:
Joins allow fetching related data across tables. The most common types include:
- INNER JOIN โ Returns matching rows from both tables.
- LEFT JOIN โ Returns all rows from the left table and matching rows from the right.
- RIGHT JOIN โ Returns all rows from the right table and matching rows from the left.
- FULL JOIN โ Returns all rows from both tables.
Example INNER JOIN:
sqlCopyEditSELECT Employees.name, Departments.department_name
FROM Employees
INNER JOIN Departments ON Employees.department_id = Departments.department_id;
Leave a Reply