Helo Folks,
我有3张桌子。 A
,B
,C
。
我在表A
行中列有' date
'有价值' 2000-1-1
'。
我想根据where A.date = '2000-1-1'
从 3 表中删除行。
考虑join on A.ID = B.ID
..或表之间的某种其他类型的连接。
答案 0 :(得分:1)
您不能对3个表发出单个delete语句,但可以在一个事务中对3个不同的表包装3个delete语句。
BEGIN TRANSACTION
DELETE FROM TABLE_A
WHERE EXISTS (SELECT 1
FROM Table_X X
WHERE TABLE_A.ID = X.ID)
DELETE FROM TABLE_B
WHERE EXISTS (SELECT 1
FROM Table_X X
WHERE TABLE_B.ID = X.ID)
DELETE FROM TABLE_C
WHERE EXISTS (SELECT 1
FROM Table_X X
WHERE TABLE_C.ID = X.ID)
COMMIT TRANSACTION;