You are here: Re: SELECT * help needed. « PHP Programming Language « IT news, forums, messages
Re: SELECT * help needed.

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация