आप having
. के साथ प्रयास कर सकते हैं :
SELECT Ads.AdId
FROM Ads
JOIN AdsAmenities ON Ads.AdId = AdsAmenities.ads_AdId
WHERE AdsAmenities.amenities_AmenityId IN (2, 18, 1)
GROUP BY Ads.AdId
HAVING COUNT(distinct AdsAmenities.amenities_AmenityId) = 3
मामले में AdsAmenities.amenities_AmenityId
मान uniq हैं, आप distinct
. छोड़ सकते हैं भाग।