ADVERTISEMENT
Google AdSense Slot (headerLeaderboard)
Set your Publisher ID in src/config/ads.ts to display live ads.
SQL Database Tutorial• 6 min read
SQL Joins Explained
INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN
A JOIN clause is used to combine rows from two or more tables, based on a related column between them (such as a foreign key).
The 4 Types of SQL Joins
1
INNER JOIN: Returns records that have matching values in both tables.2
LEFT JOIN: Returns all records from the left table, and matched records from the right table.3
RIGHT JOIN: Returns all records from the right table, and matched records from the left table.4
FULL OUTER JOIN: Returns all records when there is a match in either left or right table.INNER JOIN Orders and Customers
SELECT
Orders.OrderID,
Customers.CustomerName,
Orders.OrderDate,
Orders.TotalAmount
FROM Orders
INNER JOIN Customers
ON Orders.CustomerID = Customers.CustomerID
ORDER BY Orders.OrderDate DESC;ADVERTISEMENT
Google AdSense Slot (inContentBanner)
Set your Publisher ID in src/config/ads.ts to display live ads.
Test Yourself With Exercise
Which JOIN returns ALL rows from the left table, even if there are no matches in the right table?