Created
July 6, 2012 23:00
-
-
Save munro/3063239 to your computer and use it in GitHub Desktop.
Intersect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- this seems slow | |
SELECT listing_id FROM tags WHERE name = 'game_hon' | |
INTERSECT | |
SELECT listing_id FROM tags WHERE name = 'west' | |
INTERSECT | |
SELECT listing_id FROM tags WHERE name = 'ap' | |
INTERSECT | |
( | |
-- Is there a more efficient way to store this? | |
SELECT listing_id FROM range_min WHERE name = 'mmr' AND value >= ${min} AND value <= ${max} | |
UNION | |
SELECT listing_id FROM range_max WHERE name = 'mmr' AND value >= ${min} AND value <= ${max} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT listing_id | |
FROM tag a | |
INNER JOIN tag b USING (listing_id) | |
WHERE a.name = 'beer' AND b.name = 'airconditioning' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment