读书人

sql查询反复的列

发布时间: 2012-07-08 17:43:43 作者: rapoo

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.主键)

记录下基础知识。

读书人网 >SQL Server

热点推荐