Delete Query where code and client are equal

marlind

Registered User.
Local time
Today, 04:17
Joined
Oct 9, 2007
Messages
19
I am trying to delete a record in tblinclude where record from tblexclude are equal to clientid and codeid

Here is the sql
DELETE tblinclude.ClientID
FROM tblexclude INNER JOIN tblinclude ON (tblexclude.ClientID = tblinclude.ClientID) AND (tblexclude.CodeID = tblinclude.CodeID)
WHERE (((tblinclude.ClientID)=1));

I get the error Specify the table containing the records you want to delete. I've searched for this but I am just not getting it today. Thanks for any help.
 
Access doesn't understand which table you want to delete records - is it the include or the exclude table?

DELETE tblinclude.ClientID
FROM tblexclude INNER JOIN tblinclude ON (tblexclude.ClientID = tblinclude.ClientID) AND (tblexclude.CodeID = tblinclude.CodeID)
WHERE (((tblinclude.ClientID)=1));

I think what you want is

Code:
DELETE * FROM tblInclude
WHERE Exists(SELECT * FROM tblExclude as Tmp WHERE clientID=tblInclude.ClientID AND CodeID=tblInclude.CodeID)=True
 

Users who are viewing this thread

Back
Top Bottom