Union Queries
Home
Up

USING UNION QUERIES

You can choose from several types of queries, but many users don't know about Union queries because the option isn't as obvious as the others. A Union query is what you need when you want to join tables of similar structure. For instance, you might want to rejoin historical data with current data (assuming you've archived historical data in a similar but different table, separate from the current data).

To create a Union query, you open the query design grid, add the appropriate tables, and then click the SQL View button (the third option on the View button). Doing so will open the SQL window, which contains the SQL equivalent of the existing query. At this point, to create a basic Union query, you should replace the existing SQL statement with a SQL statement in the form

SELECT [field] FROM [firsttable] UNION SELECT [field] FROM [secondtable]

where field represents the field you want to display in your query results and firsttable and secondtable are the names of the two tables you want to join. To include all the fields in your query, you can replace [field] with the * character. Just remember, the fields must match in each table.


page last updated: Monday, 24. May 1999 09:47:09 -0500