MySQL删除表中重复数据并仅保留id最小的一行

删除表中重复数据并仅保留id最小的一行:

delete from douyin where descTitle in

(select pname from

(select descTitle as pname from douyin group by descTitle having count(descTitle)>1)

a)

and

num not in

(select pnum from

(select min(num) as pnum from douyin group by descTitle having count(descTitle)>1)

b);

posted @ 2021-04-21 10:41  今天我养哈士奇了吗  阅读(143)  评论(0)    收藏  举报