Unions are used to retrieve records from multiple tables or to get multiple record sets from a single table.
/* Get the phone numbers of all shippers, customers, and suppliers */ SELECT CompanyName, Phone FROM Shippers UNION SELECT CompanyName, Phone FROM Customers UNION SELECT CompanyName, Phone FROM Suppliers ORDER BY CompanyName;
This query will return the company name and phone number of all shippers, customers and suppliers.
By default, all duplicates are removed in
UNIONs. To include duplicates, use
UNION ALL in place of