A表和B表拥有相同的联合主键column1,column2, column3
正确的语句:
delete from TableA
where not exists (
select 1 from TableB b
where TableA.column1 = b.column1
and TableA.column2 = b.column2
and TableA.column3 = b.column3 )
and TableA.column4 = '20100804'
以上代码值得注意和强调的地方是 TableA 不能使用别名,例如以下编写就是错的:
delete from TableA a
where not exists (
select 1 from TableB b
where a
.column1 = b.column1
and a
.column2 = b.column2
and a
.column3 = b.column3 )
and a
.column4 = '20100804'
DB因为不识别TableA的别名a,导致语法错误。