Update/Insert Records If Not Exist

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

Guest

I have two table; TableA and TableB having the same structure. TableB has
some records that do not exist in TableA. How do I write a Query to update
TableA to INSERT records from TableB (ONLY RECORDS THAT DO NOT EXIST IN
TABLEA).
Thanks
 
To find something that does not exist in another table you would use an
Outer Join.

e.g.
SELECT Customers.CustomerID
FROM Customers LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID
WHERE (((Orders.CustomerID) Is Null));

So, you could use one query to find those that don't exist, then a second to
perform the Append.
 

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