Question on Delete Query

M

Michael D. McGill

I am trying to run a delete query by comparing two tables (tableA and
tableB) I do this by linking the two tables on a unique field and I want to
delete all records from tableA that are not in tableB. tableA is originally
made by a Make Table query.

Here is the SQL:

DELETE local_cmn_detail_info.*, cmn_detail_info_snapshot.Expr1
FROM local_cmn_detail_info LEFT JOIN cmn_detail_info_snapshot ON
local_cmn_detail_info.Expr1 = cmn_detail_info_snapshot.Expr1
WHERE (((cmn_detail_info_snapshot.Expr1) Is Null));

When I try to run this I get the following error:

Could not delete from specified tables.

The Help on it isn't much help.

Any ideas?
Thanks,
Mike
 
K

Ken Snell

Assuming that "local_cmn_detail_info" is the TableA in your post:

DELETE local_cmn_detail_info.*
FROM local_cmn_detail_info LEFT JOIN cmn_detail_info_snapshot ON
local_cmn_detail_info.Expr1 = cmn_detail_info_snapshot.Expr1
WHERE (((cmn_detail_info_snapshot.Expr1) Is Null));

You don't include the linking field from TableB in the SELECT clause.
 

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