Home >Database >Mysql Tutorial >按某几列删除表中重复数据

按某几列删除表中重复数据

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 14:53:341144browse

按某几列删除表中重复数据 开始获取了重复列的数据,想了好久不知道怎么在那基础上删除,最后仔细一想,通过下面那个sql多执行几次知道执行结果为0就表示重复数据已经删除了撒 www.2cto.com delete from warehouse_summary t where t.summary_id in ( select


按某几列删除表中重复数据

 

开始获取了重复列的数据,想了好久不知道怎么在那基础上删除,最后仔细一想,通过下面那个sql多执行几次知道执行结果为0就表示重复数据已经删除了撒

  www.2cto.com  

delete from warehouse_summary t where t.summary_id in (

select min(t.summary_id) 

  from warehouse_summary t

  left join warehouse_Info wi

    on t.warehouse_id = wi.warehouseid

 where 

    t.status = 1 group by wi.warehouseid,t.product_id having count(*)>1  

)

delete from people

where peopleId in (select peopleId from people group by peopleId   

having count(peopleId) > 1)

and rowid not in (select min(rowid) from people group by peopleId having count(peopleId )>1)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn