EZ

Eduzan

Learning Hub

Eduzan
Eduzan / SQL

JOIN Operations in SQL

Definition: A JOIN operation in SQL, by default or when specified as an INNER JOIN, combines rows from two or more tables based on a related column between them, returning rows where there is at least one match in both tables.

Example:

-- INNER JOIN between Customers and Orders tables on the CustomerID
SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID;

Explanation: This query retrieves the customer name and order ID for all orders. If a customer has no orders, they do not appear in the result set. Conversely, if there are no matching customers for an order, that order is excluded.

End of lesson.