我有此SQL查询来选择所有没有订单的重复客户:
select distinct * from [KUNDEN] k1
where not exists (
select * from [BELEG] b
where k1.Nummer = b.Adressnummer)
and exists (
select * from [KUNDEN] k2
where k1.Nummer <> k2.Nummer
and k1.Name = k2.Name
and k1.Vorname = k2.Vorname)
我如何更改此查询以删除这些客户?
谢谢你的帮助
最佳答案
delete from [KUNDEN]
where nummer in (
select distinct nummer
from [KUNDEN] k1
where not exists (
select * from [BELEG] b
where k1.Nummer = b.Adressnummer)
and exists (
select * from [KUNDEN] k2
where k1.Nummer <> k2.Nummer
and k1.Name = k2.Name
and k1.Vorname = k2.Vorname)
)
关于mysql - 删除SQL中的重复记录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31519089/