How about:
SELECT * FROM tableA
UNION
SELECT * FROM tableB;
The UNION versus UNION ALL will eliminate any duplicate records.
Main Topics
Browse All TopicsI have two tables in Access that I am trying to merge. I have a query that selects records from both tables when a related field is equal and places the results in a new table. But, I also want to include the records that don't match in that new table as well. If records from Table A match records in Table B, join the results, but if they don't, still include them in the resulting table.
Is there an easier way to do this than going through Tables A and B by hand?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I'll clarify a bit lol.
I have Table A which has some descriptions and extended information for particular items. Table B has more information which I want to join using related Item ID's (the two tables were created from two excel worksheets). So, if the Item ID's match in Table A and Table B, join all fields relative to the Item ID. And, in the event that they don't match, still include those unmatched records in Table C.
If you want an example, I can copy the structure and include some sample data.
Aside from ItemID, the fields in TableB are different from those in TableA? So if there are 5 fields in TableA and 10 in TableB, Then TableC will have 5+10 fields(repeating the ItemID), the first several of which will all be filled and the last part containing the 10 fields from TableB for which there is no ItemID match in TableA - correct?
It might be a good idea to give us the sample structure(s) and data.
Business Accounts
Answer for Membership
by: mvasilevskyPosted on 2009-07-26 at 11:39:54ID: 24946877
Not sure I'm understanding but it sounds like you want all records from both tables in a new table?
INSERT INTO TableC ( Field1,Field2,Field3)
SELECT Field1, Field2, Field3
FROM TableA; UNION SELECT Field1, Field2, Field3
FROM TableB;
Or if you have the join query:
INSERT INTO TableC (Field1,Field2,Field3)
SELECT Field1, Field2, Field3
FROM TableA INNER JOIN TableB on Field4
you could get the not matching records with (assuming Field1 is your primary key field):
INSERT INTO TableC (Field1,Field2,Field3)
SELECT Field1, Field2, Field3
FORM TableA
WHERE Field1 NOT IN (SELECT Field1, Field2, Field3
FORM TableA INNER JOIN TableB on Field4); UNION SELECT Field1, Field2, Field3
FORM TableB
WHERE Field1 NOT IN (SELECT Field1, Field2, Field3
FORM TableA INNER JOIN TableB on Field4);
The UNIONs assume TableA and TableB have the same fields.
HTH,
mv