--建立测试环境
set nocount on
create table test(bevyman_id varchar(20),bevy_id varchar(20),man_id varchar(20))
insert into test select '1','1','1'
insert into test select '2','1','2'
insert into test select '3','3','1'
insert into test select '4','3','5'
insert into test select '5','2','3'
go
--测试
select * from test a where exists(select 1 from
test where man_id=1 and bevy_id=a.bevy_id and man_id<>a.man_id)
--删除测试环境
drop table test
set nocount off