mysql查询两个字段下重复数据的删除方法
我有一个数库表,表名为credit,里面有这几名数值,person_id,project_id等,我想查询,project_id和person_id,重复的数据,并删除p...
我有一个数库表,表名为credit,里面有这几名数值,person_id,project_id等,我想查询,project_id和person_id,重复的数据,并删除project_credit_id值大的记录(就是只删除后面两条)。谢谢。
这个数据库里有很多这样子的数据,谢谢。 展开
这个数据库里有很多这样子的数据,谢谢。 展开
展开全部
删除重复的
DELETE from credit where project_credit_id NOT IN (
select t.project_credit_id(
select max(project_credit_id) as project_credit_id from credit group by person_id,project_id having count(*)>1
)t)
DELETE from credit where project_credit_id NOT IN (
select t.project_credit_id(
select max(project_credit_id) as project_credit_id from credit group by person_id,project_id having count(*)>1
)t)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询