在网上查找删除重复数据保留id最小的数据,方法如下:
1 DELETE FROM Teacher 2 WHERE Name IN( 3 SELECT Name 4 FROM Teacher 5 GROUP BY Name 6 HAVING COUNT(Name)>1 7 ) 8 AND Id NOT IN( 9 SELECT MIN(Id) 10 FROM Teacher 11 GROUP BY Name 12 HAVING COUNT(Name)>1 13 )
在网上查找删除重复数据保留id最小的数据,方法如下:
1 DELETE FROM Teacher 2 WHERE Name IN( 3 SELECT Name 4 FROM Teacher 5 GROUP BY Name 6 HAVING COUNT(Name)>1 7 ) 8 AND Id NOT IN( 9 SELECT MIN(Id) 10 FROM Teacher 11 GROUP BY Name 12 HAVING COUNT(Name)>1 13 )