Comparing two tables.

P

philman

I'm a SQL newbie so please bare with me. I have two tables that I want to
query against and determine what records exist in the first that don't exist
in the second and vice versa. I'm wondering what is the most efficient means
to find and add the records that exist in the first table but not in the
second table to the second table. Also, I want to delete any records that
exist in the second table but don't exist in the first from the second table
(sorry, not a very clear description, I know). Any advise would be greatly
appreciated.
 
P

philman

I failed to mention that what I'm trying to do is end of with two identical
recordsets (or tables). I can't simply delete all records from the second
table and add in each record from the first table because there are
additional fields in the second table that I need to retain for any records
that exist in both tables (still a poor description!).
 
J

John W. Vinson

I'm a SQL newbie so please bare with me. I have two tables that I want to
query against and determine what records exist in the first that don't exist
in the second and vice versa. I'm wondering what is the most efficient means
to find and add the records that exist in the first table but not in the
second table to the second table. Also, I want to delete any records that
exist in the second table but don't exist in the first from the second table
(sorry, not a very clear description, I know). Any advise would be greatly
appreciated.

What constitutes "the same"? Do you have a Primary Key that you can use to
match records, or do you need to compare the entire record field by field -
and if so how many fields?
 

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