Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Delete

Status
Not open for further replies.

BNPMike

Technical User
Joined
Sep 17, 2001
Messages
1,818
Location
GB
I have a table "log" and I want to delete those records I have assembled in a second table "Cleanups". So I join the two tables and turn the query into a delete.

I get something like this

DELETE Cleanups.ID, log.ID
FROM Cleanups INNER JOIN log ON Cleanups.ID = log.ID;

I now edit this to:

DELETE log.ID
FROM Cleanups INNER JOIN log ON Cleanups.ID = log.ID;

Access then says "specify the table containing the records you want to delete."

Is my SQL plain bad or is Jet being unfair?

..............What I had to do is:


DELETE log.ID
FROM log
WHERE log.ID in
(SELECT Cleanups.ID
FROM Cleanups
WHERE (((Cleanups.INo) Is Null)));


 
Provided Cleanups.ID and log.ID are the PrimaryKey in their respective table:
Code:
DELETE log.*
FROM log INNER JOIN Cleanups ON log.ID = Cleanups.ID
WHERE Cleanups.INo Is Null

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top