我有两张桌子t1
,t2
有列name, invoice, total
。
我正在使用此查询来获取 T2 中而不是 T1 中的行
select *
from t2
where name = (select source from info)
except
(select * from t1)
它工作正常并返回几行,我想要的是在一个语句中删除这些返回的行。
我已经尝试过了,但它不仅删除了查询中返回的行,还删除了 T2 中的所有行。
delete from t2
where exists ((select *
from t2
where name = (select source from info)
except
(select * from t1)
))
这是我的数据示例:
T1
T2
返回的数据(存在于 T2 中,而不存在于名称为 C2 的 T1 中)
第三个表信息是获取名称,在这种情况下是 C2。
提前致谢。