Perhaps,
Code:select name from photos where id in (select photo_id from photo_tags where tag_id in (6, 13);
Perhaps,
Code:select name from photos where id in (select photo_id from photo_tags where tag_id in (6, 13);
Last edited by winch; July 21st, 2007 at 04:36 PM. Reason: distinct not needed
OpenStreetMap - Free editable map of the whole world
Yeah, I guess I'll just use it. It seems kinda strange that it's not a better way. I'd assume this kind of problem pops up fairly often
Opps.
You could also do this,
That will work as long as the photo_tags table doesn't have duplicate rows.Code:select name from photos where id in(select photo_id from (select photo_id, count(*) as count from photo_tags where tag_id in (6, 13) group by photo_id) where count = 2);
Last edited by winch; July 21st, 2007 at 08:34 PM.
OpenStreetMap - Free editable map of the whole world
Bookmarks