我有这个表(tblStudent)在Sql Server:
<表类>
Id
名称
年龄
PlaceOfBirthId
CityId
tbody><<tr>1 N1 11 2 3 2N2 19 4 6 3 N3 11 3 56 4陶瓷 14 8 11 5它们 13 27 12 6N6 21 25 45 7N7 33 9 7 8N8 23 8 71 9 N9 15 76 71 10N10 41 13 3 表类>
你可以这样做:
select *
from tblstudent s
where exists (
select 1 from filter f
where f.filterid = 1 and f.filtervalue = s.placeofbirth
)
and exists (
select 1 from filter f
where f.filterid = 2 and f.filtervalue = s.cityid
)