Help me,
I want to delete same filed name from two tables in single query, I Attached query but it's not working…
DELETE PersonalTrainerMasterData ,PersonalTrainerCheckboxData
FROM PersonalTrainerMasterData INNER JOIN PersonalTrainerCheckboxData
WHERE PersonalTrainerMasterData.ButtonName = PersonalTrainerCheckboxData.ButtonName
and PersonalTrainerMasterData.ButtonName='" + deleteButtonForm.getButtonToBeDeleted()
+ "'and TabID=1";
Best Answer
A DELETE only affects one table at a time and removes all rows that are defined in the
criteria
. Notice the syntax description:You should be able to wrap two
DELETE
statements in a transaction. BecausePersonalTrainerMasterData
contains the criteria,DELETE
it last. E.g.If needed you could also insert logic to decide whether the
DELETE
should be allowed toCOMMIT
or if it shouldROLLBACK
.