I have 3 tables.
mainT
has primary keymain_id
sub1T
has foreign key tomain_id
sub2T
has foreign key tomain_id
I need to delete all records from sub1T
and sub2T
in one SQL command.
I know how to delete all records inside sub1T using this command:
DELETE FROM `sub1T`
WHERE NOT EXISTS (SELECT NULL
FROM mainT
WHERE `mainT`.main_id = main_id)
I need to delete from multiple child tables