Skip to content

Instantly share code, notes, and snippets.

@gabidavila
Created August 8, 2017 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabidavila/1dfa8cb29c3788bdecdbdde947874c4f to your computer and use it in GitHub Desktop.
Save gabidavila/1dfa8cb29c3788bdecdbdde947874c4f to your computer and use it in GitHub Desktop.
SELECT `boats`.*
FROM `boats`
INNER JOIN `boat_classifications`
ON `boat_classifications`.`boat_id` = `boats`.`id`
INNER JOIN `classifications`
ON `classifications`.`id` = `boat_classifications`.`classification_id`
GROUP BY `boats`.`id`
HAVING count(classifications.id) = 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment