[thelist] Fetching rows 5 above and 5 below a target row...

Tris beertastic at gmail.com
Mon Dec 18 08:30:51 CST 2006


I see...
I can then adda  limit 10 to only fetch the correct No of rows..
However, that page dies not seem to say how to ensure my result sits
in teh middle..

If every user has a score of 100, it'll pick out the first 10 only..
that's not good...

But I've learnt something today, I just need to learn a littl emore..

Tris...



On 18/12/06, Mark Groen <evolt at markgroen.com> wrote:
> On Monday 18 December 2006 02:16, Tris wrote:
> > Hi all...
> >
> > I've been asked to put together a league table thingy for a client.
> > What they want is to show the current users position, relative to the
> > whole board.
> >
> > So, If I'm ranked 356 for example, on my leauge table view, I wanna
> > see me highlighted inthe middle and Ranks 350 - 355 above me, and then
> > 357 - 361 below me.
> >
> > each user in the DB has a score tally, that increments as the user
> > plays the game. (It's a quiz thing).
> >
> > So eg:
> >
> > SELECT userName, score FROM resultsTable WHERE userName =
> > '$myUserName' (and 5 above/below too!) ORDER BY score DESC LIMIT 11
> >
> > Is this easy, google is making my Monday morning hard... :-(
> >
> > Tris...
>
> The Operator you are looking for is BETWEEN, here's a tute:
>
> http://www.webdevelopersnotes.com/tutorials/sql/tutorial_mysql_in_and_between.php3
>
> --
> cheers,
>
>        mark
> --
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>



More information about the thelist mailing list