Union Query Problem

  • Thread starter Alastair MacFarlane
  • Start date
A

Alastair MacFarlane

Dear All,

If I create 2 tables with the following properties:

TableA: Code (Text,1); Value (Number, Integer)
TableB: Code (Text,1); Value (Number, Integer)

If I add identical values in both tables:

TableA Value added: A (in Code); 100 (in Value)
TableB Value added: A (in Code); 100 (in Value)

And then run the following UNION Query:

SELECT * FROM TABLE1;
UNION SELECT * FROM TABLE2;

I get only one value returned:

Code: A and Value = 100

If you have different values in table A or B then I will get 2 records
returned.

How Can I ensure that all records are returned including the duplicates from
TableA and TableB. Access seems to 'Hide' one of the values. Why and how can
I fix this?

Thanks again.

Alastair MacFarlane
 
B

Brendan Reynolds

SELECT * FROM TABLE1;
UNION ALL SELECT * FROM TABLE2;

Note the addition of the keyword 'ALL'.
 
A

Alastair MacFarlane

Brendan,

Thanks for the quick reply. I appreciate your time this Saturday evening (UK
time).

Alastair
 

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