Combining 2 queries into 1 query with same data field

G

Guest

I tried to search for the answer in here but can't seem to find one that
answers my needs. I have 2 queries that perform different operations to the
same table. The output have the same fields. How do I combine the output of
these 2 queries back to one query?

Table:
field1 field2
a b
c d

Query1
field1 field2
am bn
cm dn

Query2
field1 field2
ax bx
cx dx

This is how I would like to get the final output:
New Query
field1 field2
am bn
cm dn
ax bx
cx dx

Thank you,
Quan
 
G

Guest

Try a UNION query: search Access' help for "Union operation" or "Union
query". Basically, using the SQL editor, you write one query, add the word
"UNION" and then write the other query, like

SELECT field1, field2 FROM Table
UNION
SELECT field1, field2 FROM Table;

There are also examples in Access' help files.

I am using your examples. You probably need to manipulate the fields
differently in the two queries - eg for your first result, the first line of
my query would read:

SELECT field1 & "m", field2 & "n"

The SQL editor can be opened from the drop-down list for the button
immediately underneath the File menu.

HTH
 
T

tina

try a Union query. the easy way to build it is to open your first query in
Design view. click View | SQL View on the menu bar to change to SQL view.
highlight the entire SQL statement and copy it. close the first query.

open the second query in design view and change to SQL view. go to the end
of the SQL statement and delete the semi-colon (;). press Enter to go to the
next line, and type UNION and then single-space. press Ctrl+v to paste the
copied SQL statement from the first query.

note the both queries must have the same number of fields returned, just as
your example shows.

hth
 
G

Guest

Thank you both. This worked perfectly.

tina said:
try a Union query. the easy way to build it is to open your first query in
Design view. click View | SQL View on the menu bar to change to SQL view.
highlight the entire SQL statement and copy it. close the first query.

open the second query in design view and change to SQL view. go to the end
of the SQL statement and delete the semi-colon (;). press Enter to go to the
next line, and type UNION and then single-space. press Ctrl+v to paste the
copied SQL statement from the first query.

note the both queries must have the same number of fields returned, just as
your example shows.

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top