Joining tables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have table A with some codes (for instance, 1, 2, 4, 5 and 7) and a table B
with some common codes and some new codes (for example, 1, 3, 4 and 6).
I would like to generate a new table C with all codes in A plus the new
codes in B (in the example, it would have codes 1, 2, 3, 4, 5, 6 and 7).
I've tried INNER JOIN, but it gives me the common codes.
Can somebody explain me how to do that? Thanks.
 
Sil said:
I have table A with some codes (for instance, 1, 2, 4, 5 and 7) and a
table B with some common codes and some new codes (for example, 1, 3,
4 and 6).
I would like to generate a new table C with all codes in A plus the
new codes in B (in the example, it would have codes 1, 2, 3, 4, 5, 6
and 7). I've tried INNER JOIN, but it gives me the common codes.
Can somebody explain me how to do that? Thanks.

You need a UNION query. This is one of a handful of queries that cannot be
created in the GUI query designer. You have to switch to SQL view.

SELECT Code
FROM TableA

UNION SELECT Code
FROM TableB

The UNION as written would automatically eliminate duplicates in the output. If
you want to create a permanent table from the results then use the UNION query
as the input to a MakeTable query.
 

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

Back
Top