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

Posted by Oli Filth on 10/19/05 17:45

Simon wrote:
> > Providing that u know what xx is there two other needed variables are
> > the xx-5 and xx+5
> >
> > so then
> >
> > $start = $xx-5;
> > $stop = $xx+5;
> >
> > SELECT * FROM Articles WHERE id >= $start AND id <= $stop;
> >
> > I think this is what you're looking for.
> >
> > Rgds,
> > Gerard
>
> I know what XX is but unfortunately the unique ID are not in sequence.
>
> So I could have articles with ID
>
> 1, 4, 5, 6, 10, 11, and so on...
>
> I don't have all the article numbers, (in the case above I don't have ID 2,
> 3, 7, 8 and 9).
>
> So doing your select would not work.
>

(SELECT * FROM Articles WHERE id >= $x ORDER BY id LIMIT 6)
UNION
(SELECT * FROM Articles WHERE id < $x ORDER BY id DESC LIMIT 5)

It's possible that the syntax isn't 100% correct, but you get the
idea...

--
Oli

 

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

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