delete from table1 where user_id = ...
delete from table2 where user_id = ...
delete from table3 where user_id = ...
delete from table4 where user_id = ...
この1つのクエリから作成しようとしましたが、結果はありません。
delete from table1 where user_id = ...
delete from table2 where user_id = ...
delete from table3 where user_id = ...
delete from table4 where user_id = ...
この1つのクエリから作成しようとしましたが、結果はありません。
私はそれがうまくいくと思う
DELETE table1.*, table2.*,table3.* FROM table1, table2, table3
WHERE table1.user_id=? and table2.user_id=? and table3.user_id=?;
うまくいくかもしれない別の解決策があります:
DELETE FROM table1, table2, table3
USING table1
INNER JOIN table2 USING(user_id)
INNER JOIN table3 USING(user_id)
WHERE table1.user_id= ?
とにかく、オプションを使用してテーブルに外部キー制約を定義しON DELETE CASCADE
、親テーブルからレコードを削除すると、子テーブルからすべてのレコードが削除されます。