我有一张桌子hotel [hotelid,hotelname,etc]
和另一张桌子facilities[facilityid,facilityname]
这两个表通过 table 链接hotel_to_facilities_map[hotelid,facility_id]
所以桌子hotel_to_facilities_map
可能包含如下值
hotelid facility_id
-------------------
1 3
1 5
1 6
2 6
2 2
2 5
现在我想检索符合所有要求的设施的所有酒店
select * from hotel_to_facilities_map where facility_id IN (3,5,2)
但这会导致比赛OR
当我需要的时候表达AND
.
有什么解决方法或解决方案吗?
select hotelid
from hotel_to_facilities_map
where facility_id in (3,5,2)
group by hotelid
having count(*) = 3
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)