Shenouda Shehata:
私は3つのテーブルを持っています
1-rests
2-amenity_rest
3-amenities
rests
id name
1 rest1
2 rest2
3 rest3
amenities
id name
1 amenity1
2 amenity2
3 amenity3
amenity_rest
rest_id amenity_id
1 1
1 3
2 2
3 1
私は[1,3]のような設備のリストを送りたいです
そしてそれは、そのidは= 1という残りを返す必要があります
私は配列[1,2,3]を送信する場合、それは何の結果を返すべきではありません
どのようなクエリは同じように見えますか?
ゴードン・リノフ:
:あなたは、としてクエリを作成することができます
select ar.rest_id
from amenity_rest ar
where ar.amenity_id in (1, 2, 3)
group by ar.rest_id
having count(*) = 3; -- "3" = size of list