Data Query Lanage(DQL): Multiple Table Search-Join && Union
2020, May 24
JOIN
Combine rows from two or more tables
SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;
- Inner Join return records that have matching values in both tables A union B
- Left Join return all records from the left table, and the matched records from the right table A
- Right Join return all records from the right table and the matched records from the left table B
- FULL Join return all records when there is a match in either left or right table AUB
UNION
Combine result from multiple SELECT statements
- Each SELECT statement must have same account of columns
- The columns must also have similiar data types.
- The columns in each SELECT statement must also be in the same order
SELECT 'Customer' As Type, ContactName, City, Country FROM Customers UNION SELECT 'Supplier', ContactName, City, Country FROM Suppliers;