当前位置: 代码迷 >> SQL >> sql查询反复的列
  详细解决方案

sql查询反复的列

热度:92   发布时间:2016-05-05 14:27:40.0
sql查询重复的列
有一个products表,我想查询里面的列name和列standard同时重复的数据。我想先查name重复,然后在name重复里查standard重复的内容,改怎么弄。
select name,standard,count(*) from products
group by name,standard
having count(*)>1

select * from products p where exists(
select 1 from products name=a.name and standard=a.standard and 主键<>a.主键)

记录下基础知识。
  相关解决方案