数据库
首页 > 数据库> > MySQL中删除重复数据只保留一条

MySQL中删除重复数据只保留一条

作者:互联网

DELETE
FROM
jk_his_zybrcryxxb a
WHERE
(a.brid, a.zycs,a.ryrq) IN (

select * FROM
(

SELECT
brid,
zycs,ryrq
FROM
jk_his_zybrcryxxb
GROUP BY
brid,zycs,ryrq
HAVING
count(*) > 1
) c


)
AND a.id NOT IN (
select * FROM
(
SELECT
max(id)
FROM
jk_his_zybrcryxxb
GROUP BY
brid,zycs,ryrq
HAVING
count(*) > 1
) d
)

标签:his,zycs,删除,重复,jk,ryrq,MySQL,zybrcryxxb,brid
来源: https://www.cnblogs.com/zhyp/p/16480014.html