Delete records if not in query

G

Guest

I have a table T1 with a key-field.

I also have a query Q1 with the same key-field. Q1 is not based on T1, but
some other tables and queries.

Now I want to delete all records in T1 that are not in Q1.

I can make an unmatched quesry finding the records to delete in T1 - but I
fail to turn it into a delete-query.

Please help.
 
N

Nikos Yannacopoulos

DELETE * FROM T1
WHERE T1.KeyField Not In (SELECT Q1.KeyField FROM Q1)

HTH,
Nikos
 

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