Home  >  Article  >  Backend Development  >  求mysql 查询重复数据的解决方法

求mysql 查询重复数据的解决方法

WBOY
WBOYOriginal
2016-06-23 14:21:591042browse

php mysql 数据

比如一个用户表,username 有相同的,怎么把这些相同的名字都查出来,,,,,,

回复讨论(解决方案)

假设你的用户表有个主键id
 select * from 用户表 t where exists(select 1 from 用户表 where username=t.username and id  t.id);

select * from tbname group by name having count(name)>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