欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

删除重复记录,并保留一条记录

程序员文章站 2022-07-15 08:50:59
...
DELETE from tiaoyaxiang_bk
 WHERE tyx_id IN (SELECT tyx_id FROM tiaoyaxiang_bk GROUP BY tyx_id HAVING COUNT(tyx_id) > 1)
   AND ROWID NOT IN
       (SELECT MIN(ROWID) FROM tiaoyaxiang_bk GROUP BY tyx_id HAVING COUNT(*) > 1);