Skip to content

Instantly share code, notes, and snippets.

@clemens
Created March 16, 2009 10:49
Show Gist options
  • Save clemens/79825 to your computer and use it in GitHub Desktop.
Save clemens/79825 to your computer and use it in GitHub Desktop.
SELECT * FROM locations
WHERE (
SELECT COUNT(*) FROM taggings
WHERE tag_id IN (
SELECT tags.id FROM tags
WHERE tags.name = 'Bar' OR tags.name = 'Restaurant'
) AND taggable_type = 'Location' AND taggable_id = locations.id
) > 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment