Skip to content

Instantly share code, notes, and snippets.

@oleander
Created May 5, 2010 20:00
Show Gist options
  • Save oleander/391346 to your computer and use it in GitHub Desktop.
Save oleander/391346 to your computer and use it in GitHub Desktop.
SELECT *
FROM
`gigs`
JOIN(
SELECT *,COUNT(gigs.channel_id) as theCount
FROM `gigs`
LEFT OUTER JOIN `songs` ON `songs`.`id` = `gigs`.`song_id`
HAVING theCount < 5
ORDER BY gigs.channel_id )
AS dt USING (channel_id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment