|
Posted by Marcin Dobrucki on 10/19/05 17:19
Simon wrote:
> 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?
SELECT * FROM article WHERE ( x-5 < id and id < x+5 )
Or pick borders as you like.
/m
Navigation:
[Reply to this message]
|