我有一张这样的表:
| id | EAN | supplier_code |
|0001|11111| aaaaaa|
|0002|22222| aaaaaa|
|0003|33333| bbbbbb|
|0004|33333| cccccc|
|0005|11111| aaaaaa|
我必须删除3和4之类的ID,因为它们是脏数据。 如何编写选择以找到它们?
类似这样的事情
SELECT id, EAN, supplier_code, COUNT( id ) AS NumDuplicati
FROM table
WHERE supplier_code <> ""
GROUP BY EAN
HAVING NumDuplicati >1
但我不能删除ID 1和5 ......
答案 0 :(得分:0)
UNTESTED:不确定你是否可以区别于......
delete from yourTable where EAN in (
Select EAN
FROM yourTable
Group by EAN
having count(distinct supplier_Code ) > 1)