假设我有下表
Person table
和personStatus table
.
declare @Persons table
(PersonId int)
insert into @Persons select 10
insert into @Persons select 11
insert into @Persons select 12
insert into @Persons select 13
insert into @Persons select 14
declare @PersonStatus table
(id int,statuss int)
insert into @PersonStatus (id,statuss) values(14,4)
insert into @PersonStatus (id,statuss) values(10,0)
insert into @PersonStatus (id,statuss) values(10,0)
insert into @PersonStatus (id,statuss) values(11,1)
insert into @PersonStatus (id,statuss) values(10,1)
insert into @PersonStatus (id,statuss) values(11,2)
insert into @PersonStatus (id,statuss) values(12,0)
insert into @PersonStatus (id,statuss) values(12,1)
insert into @PersonStatus (id,statuss) values(12,2)
insert into @PersonStatus (id,statuss) values(13,1)
insert into @PersonStatus (id,statuss) values(13,3)
现在我想找到他们的状态只是在这个集合 {0,1,2} 结果是---> 10,11,12
怎么做?