Comparing two tables.

  • Thread starter Thread starter philman
  • Start date Start date
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.
 
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!).
 
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?
 
Back
Top