Created
July 14, 2011 08:47
-
-
Save smiler/1082116 to your computer and use it in GitHub Desktop.
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 c.channel | |
from channels c | |
where c.id in (select ct.channelid | |
from channel_tags ct | |
join tags t on ct.tagid = t.id | |
where t.tag = 'tag 1') | |
and c.id in (select ct.channelid | |
from channel_tags ct | |
join tags t on ct.tagid = t.id | |
where t.tag = 'tag 2') | |
select c.channel | |
from channels c | |
join channel_tags ct on c.id = ct.channelid | |
join tags t on t.id = ct.tagid | |
where t.tag in ('tag 1', 'tag 2') | |
group by c.channel, | |
ct.channelid | |
having COUNT(ct.channelid) = 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment