AlphaPress Publishing
P.O. Box 5942 Albany, NY 12205
Tel: 518-250-3890
Email: alphapress@hotmail.com  


  
Click to buy this book from Amazon

Section Menu 

News

Pindaro is now working on a comprehensive book on SQL Server 2014.  For any comments you can email the author at alphapress@hotmail.com.

  

 

 

The UNION operator with dissimilar fields

To contact the author click here

This article is from the book "Access 2007 Pure SQL

To download the sample database click here


 

The UNION operator with dissimilar fields

Combine customer and supplier records from two different tables

Discussion:

Here, we demonstrate the ability of the UNION statement to combine data from two dissimilar tables.  Notice the different field names from the customer and supplier tables.  In addition, check the numbers. We get all of the customers from the customers table (201) and all of the suppliers (10) from the suppliers table. 

Code:

SELECT lastname, firstname, city, state, zip

FROM customers

UNION

SELECT companyname, contactname, city, state, zip

FROM suppliers
 

Result: