Query from two tables to compare

  • Thread starter Thread starter de Vroede
  • Start date Start date
D

de Vroede

Hi,

I'm having difficulty building a query that compares two tables. I'm
using access 2000 on win2000.

I have a hardware db that contains a table with hardware, a table with
users and a table where hardware is linked to users (called tbl_assets)
..

I filled the hardware list from an excel file and I want to update the
asset table with data from the hardware list and link them to a default
user. but I don't want to have multiple values, so values allready in
the asset table should be skipped.

I've tried to use a criteria that should exclude values in the
tbl_assets IDhardware column, but the query doesn't like that.

regards,

jeroen
 
You can do it with a sub-query ...

INSERT INTO TargetTable (TargetID, TargetText) SELECT SourceID, SourceText
FROM SourceTable WHERE SourceID NOT IN (SELECT TargetID FROM TargetTable)
 
Thanks,

this works great!

regards,

jeroen

Brendan said:
You can do it with a sub-query ...

INSERT INTO TargetTable (TargetID, TargetText) SELECT SourceID, SourceText
FROM SourceTable WHERE SourceID NOT IN (SELECT TargetID FROM TargetTable)
 

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