select id,name from 表 group by id,name having count(*)>1
select * from table where name in( select name from table group by name having count(name)>1)
select id,name from 表 group by id,name having count(*)>
--掉了个'1' select id,name from 表 group by id,name having count(*)>1
declare @t table(id int,name varchar(18)) insert @t select 1,'121212' union all select 1,'121212' union all select 3,'121211' select a.* from @t a, (select name from @t group by name having count(name) > 1) b where a.name = b.nameselect * from @t where name in(select name from @t group by name having count(1) > 1)/* id name ----------- ------------------ 1 121212 1 121212(所影响的行数为 2 行)id name ----------- ------------------ 1 121212 1 121212 */
select name from table
group by name
having count(name)>1)
select id,name
from 表
group by id,name
having count(*)>
select id,name
from 表
group by id,name
having count(*)>1
insert @t
select 1,'121212' union all
select 1,'121212' union all
select 3,'121211'
select a.*
from @t a,
(select name from @t group by name having count(name) > 1) b
where a.name = b.nameselect *
from @t
where name in(select name from @t group by name having count(1) > 1)/*
id name
----------- ------------------
1 121212
1 121212(所影响的行数为 2 行)id name
----------- ------------------
1 121212
1 121212
*/