|
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]
|