私はこれをしたい:
delete from table1 a,table2 b, table3 c
where a.col1 = b.col1
and b.col2 = c.col2
and a.co3 <> 8001;
しかし、それは私にエラーを与えます。
私はこれをしたい:
delete from table1 a,table2 b, table3 c
where a.col1 = b.col1
and b.col2 = c.col2
and a.co3 <> 8001;
しかし、それは私にエラーを与えます。
最初に最下位レベルを削除し、そこからレベルごとに 1 つずつ削除して、最上位レベルに移動します。
DELETE FROM ChildTable WHERE ParentID=...
DELECT FROM ParentTable WHERE ParentID=...
カスケード削除をオンにしてから、親レコードを削除できます。
各テーブルに外部キーがあり、どのフィールドにあるのかを指定していないので、推測します:
Delete TableC
Where Exists( Select 1 From TableA Where TableA.Col1 = TableC.Col2 And TableA.Col3 <> '8001' )
Delete TableB
Where Exists( Select 1 From TableA Where TableA.Col1 = TableB.Col2 And TableA.Col3 <> '8001' )
Delete TableA
Where Col3 <> '8001'
a.col1 = b.col1
および b.col2 = c.col2
および a.co3 <> 8001の table1 a、table2 b、table3 c から A を削除します。