A query that shows "deletable" records

  • Thread starter Thread starter Lasse T
  • Start date Start date
L

Lasse T

Hello
Can anyone tell me how to find records in a table that has no related
records in two other tables?

I want to find the records that I can delete without having to just try
record after record.

It woud be nice if I also could delete records from that query.

Thanks in advance.

Lasse T
------------
 
Lasse

I believe the Query Wizard includes a "not in" query. It sounds like you
are trying to find records in Table1 that are "not it" Table2.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Hello
Can anyone tell me how to find records in a table that has no related
records in two other tables?

I want to find the records that I can delete without having to just try
record after record.

It woud be nice if I also could delete records from that query.

Thanks in advance.

Lasse T

Well, back up your database first just in case this blows up but...

SELECT * FROM Table1
LEFT JOIN Table2
ON Table1.keyfield = Table2.keyfield
WHERE Table2.keyfield IS NULL;

This "frustrated outer join" query will find all records in Table1 which have
no match in table2, and (if you have defined a relationship) will be
updateable. Try it this way first and then change the word SELECT to DELETE
and run it... you DID make a backup, *right*?

John W. Vinson [MVP]
 

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