"Tim Mohler" <[EMAIL PROTECTED]> wrote
in message
news:[EMAIL PROTECTED]
> select stories.*,tags.name from stories left outer join story_tags on
> stories.article_id = story_tags.article_id left outer join tags on
> story_tags.tag_id = tags.id and stories.article_id in (select
> article_id from stories order by postingdate desc limit 0,20);
Try
select stories.*,tags.name from
stories left outer join story_tags on stories.article_id =
story_tags.article_id
left outer join tags on story_tags.tag_id = tags.id
WHERE stories.article_id in (select article_id
from stories order by postingdate desc limit 0,20);
(the only difference from yours is that the last condition is moved into
WHERE clause). I believe your original query selects the last 20
articles as well as all articles that don't have any tags on them (which
forces the engine to look at every article).
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users