Appending Records from Table to Table

S

Stephen sjw_ost

Hello, Let me just say that I think you guys are the best and I appreciate
all the help you have given me in the past.

I need your help again. I have 2 databases.
DB1 has IDs in it that are used to identify my agents.
DB2 also has these IDs but is updated by managers. Managers add new agents
to DB2 as new classes come in.

So, DB2 has IDs that are already in DB1, just without all of the details of
DB1. How can I append only the records from DB2 to DB1 that are NOT already
in DB1?

I hope this makes sense.
Thank you for any help!
 
J

John W. Vinson

So, DB2 has IDs that are already in DB1, just without all of the details of
DB1. How can I append only the records from DB2 to DB1 that are NOT already
in DB1?

Use an "Unmatched Query" as an Append query:

INSERT INTO DB1(field, field, field, field)
SELECT field, field, field, field
FROM DB2 LEFT JOIN DB1
ON DB1.ID = DB2.ID
WHERE DB1.ID IS NULL;

Use your actual fieldnames of course.

Try it first without the first line (the INSERT INTO) to make sure it is
selecting the right records, and back up your database before running 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

Top