|
Posted by Simon on 10/19/05 17:14
Hi,
If I have a lot of articles, all with a unique IDs.
First I would like to search for that ID, I could do
SELECT * from ARTICLE where ID = xx
But I also want to display the 5 articles before and after that article.
SELECT * from ARTICLE where ID > xx LIMIT 0, 10
and
SELECT * from ARTICLE where ID < xx LIMIT 0, 10
(I choose a limit of 10 in case the ID is one of the first one or one of the
last one, that way I will always have at least 10 articles).
Is it possible to do the above in one single query?
Should I even bother doing that? does it make the whole operation faster to
do it that way?
Many thanks.
Simon
[Back to original message]
|