mysql 找到重複數據、並刪除


根據處理方式不同:


select a.*,if(@tmp=CONCAT(r_content,r_userid),@rownum:=@rownum+1,@rownum:=1) as rownum,@tmp:=CONCAT(r_content,r_userid) from (

select a.* from reviews a INNER JOIN

  (select r_content,r_userid,count(*) from reviews     GROUP BY r_content,r_userid having count(*)>1 ) b

 on a.r_content=b.r_content and a.r_userid=b.r_userid ) a,(select @rownum:=0,@tmp:='') b 


delete from xxx where r_id in 


或者


 select GROUP_CONCAT(r_id) as ids,r_content,r_userid,count(*) from reviews GROUP BY r_content,r_userid

HAVING count(*)>1 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章