首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

sql查询反复的列

2012-07-08 
sql查询重复的列有一个products表,我想查询里面的列name和列standard同时重复的数据。我想先查name重复,然

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

记录下基础知识。

热点排行
Bad Request.