Selecting Data Using Queries in Microsoft Access 2013

  • 3/15/2013

Adding two sets of query results together

When you have two or more sets of data that have the same number of columns, same column order, and similar column data types, and you want to combine them into a single list (although this cannot be graphically displayed), you can do so by creating a special type of query called a UNION query. This query uses a special keyword UNION (meaning bring together) or UNION ALL (meaning bring together and show duplicates). You can combine multiple blocks of SQL with this keyword.

In our example, we have two tables, called Customers and OldCustomers, and we want to show the data in both tables in a single list.

Add two result sets together

  1. In design view, add your first table to the query grid and display the desired fields.

  2. Switch the query to SQL View.

  3. Remove the semicolon (;) from the end of the SQL query, highlight the SQL query, and copy the SQL query to the clipboard.

  4. On a new line, type the keyword UNION.

  5. On a new line, paste in the copied SQL query, and change any references in the copied SQL query to refer to the second table and column names. The order of fields, number of fields, and data types should be identical in both sections of the SQL query. Field names can be different.