是不是A字段对应多个B字段的意思?select A from [tableName] group by A having count(b) > 1
同意楼上 select A from [tableName] group by A having count(1) > 1
create table tb(A int , B varchar(10)) insert into tb select 1, 'a' insert into tb select 2 , 'b' insert into tb select 2 , 'c' insert into tb select 3 , 'd' insert into tb select 4 , 'd' insert into tb select 5 , 'd' insert into tb select 5 , 'c' select * from tb where a in (select A from tb group by A having count(b) > 1)
select * from t where A in (select A from t group by A having count(1)>1)
同意楼上
select A from [tableName] group by A having count(1) > 1
insert into tb select 1, 'a'
insert into tb select 2 , 'b'
insert into tb select 2 , 'c'
insert into tb select 3 , 'd'
insert into tb select 4 , 'd'
insert into tb select 5 , 'd'
insert into tb select 5 , 'c' select * from tb where a in (select A from tb group by A having count(b) > 1)
where A in (select A from t group by A having count(1)>1)