A JOIN clause is used to combine rows from two or more tables, based on a related column between them.
There are four types of join in MySQL:
INNER JOIN: Returns records that have matching values in both tablesLEFT JOIN: Returns all records from the left table, and the matched records from the right tableRIGHT JOIN: Returns all records from the right table, and the matched records from the left tableCROSS JOIN: Returns all records from both tables
Example:
SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;
0 Comments