Re: Delete with join query
You need to delete each table individually. You can't delete two tables in one statement.
Re: Delete with join query
Ok, thanks for the answer. I believe it was possible.
So, If I should do this this individually, I must start with table tblCustDesc. How should the queries look lik then? Like this? Or do you have any other better solutions?
Code:
DELETE FROM tblCustDesc
WHERE state_ID IN ( SELECT StateDef.ID FROM StateDef WHERE StateDef.Description='OK')
And Order_ID IN ( SELECT tblCust.ID FROM tblCust WHERE tblCust.StartedBy Is Null)
And Order_ID IN ( SELECT tblCust.ID FROM tblCust WHERE tblCust.state_ID =
( SELECT StateDef.ID FROM StateDef WHERE StateDef.Description = 'OK');
'Execute the query
DELETE FROM tblCust
WHERE state_ID IN ( SELECT StateDef.ID FROM StateDef WHERE StateDef.Description='OK')
And ID Not IN ( SELECT tblCustDesc.Order_ID FROM tblCustDesc WHERE state_ID IN
( SELECT StateDef.ID FROM StateDef WHERE StateDef.Description <> 'OK')
And tblCust.StartedBy Is Null;
'Execute the query
Re: Delete with join query
Last one is missing a close ) before the last And
Re: Delete with join query
OK, so this is the right way to do the delete query?
Code:
DELETE FROM tblCustDesc
WHERE state_ID IN ( SELECT StateDef.ID FROM StateDef WHERE StateDef.Description='OK')
And Order_ID IN ( SELECT tblCust.ID FROM tblCust WHERE tblCust.StartedBy Is Null)
And Order_ID IN ( SELECT tblCust.ID FROM tblCust WHERE tblCust.state_ID =
( SELECT StateDef.ID FROM StateDef WHERE StateDef.Description = 'OK'));
'Execute the query
DELETE FROM tblCust
WHERE state_ID IN ( SELECT StateDef.ID FROM StateDef WHERE StateDef.Description='OK')
And ID Not IN ( SELECT tblCustDesc.Order_ID FROM tblCustDesc WHERE state_ID IN
( SELECT StateDef.ID FROM StateDef WHERE StateDef.Description <> 'OK'))
And tblCust.StartedBy Is Null;
'Execute the query
Re: Delete with join query