appending new Records only

murlen

Registered User.
Local time
Today, 12:31
Joined
Nov 18, 2002
Messages
37
I have three tables, table 1 'ServerTest' contains 5 records which should not change, table 2 'Region' has 40+ records.
using an append quary all records are combined into table 3 'Junction1'

my problem...
the Region table will change over time and new records will be added.
how do I append the new records only to the junction1 table?

this is my append quary;
INSERT INTO Junction1 ( RegionID, TestID, TestNumber, TestDescription )
SELECT Region.RegionID, ServerTest.TestID, ServerTest.TestNumber, ServerTest.TestDescription
FROM Region, ServerTest;


thanks :)
Murlen
 
Try this:-

INSERT INTO Junction1 ( RegionID, TestID, TestNumber, TestDescription )
SELECT [Region].[RegionID], [ServerTest].[TestID], [ServerTest].[TestNumber], [ServerTest].[TestDescription]
FROM Region, ServerTest
WHERE Region.RegionID not in (Select RegionID from Junction1);

It will insert only the new RegionIDs.

Note
Using NOT IN is inefficient if the tables Region and Junction1 are large.
.
 
that works

Thanks for the help!



... this place is great! :D
 
Does it work in MS Access' query?

Because I try to use similar style in the query of the MS Access, it give out the error message "Query is too complex".

thanks.
 

Users who are viewing this thread

Back
Top Bottom