Unix Technical Forum

Find records either side of the record found

This is a discussion on Find records either side of the record found within the MySQL forums, part of the Database Server Software category; --> I need to search a table and find a specific record. This I can do, altho I then need ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 10:02 AM
Iain Adams
 
Posts: n/a
Default Find records either side of the record found

I need to search a table and find a specific record. This I can do,
altho I then need to find 49 people either side of this record when
ordered by rank.

I.e I have loads of people who are ranked. Want to choose a player and
then find the people either side of that player.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 10:02 AM
Willem Bogaerts
 
Posts: n/a
Default Re: Find records either side of the record found

> I need to search a table and find a specific record. This I can do,
> altho I then need to find 49 people either side of this record when
> ordered by rank.
>
> I.e I have loads of people who are ranked. Want to choose a player and
> then find the people either side of that player.


Sounds like a job for the HANDLER statement:

http://dev.mysql.com/doc/refman/5.1/en/handler.html

Best regards,
--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 10:02 AM
strawberry
 
Posts: n/a
Default Re: Find records either side of the record found

On Jun 15, 1:21 pm, Willem Bogaerts
<w.bogae...@kratz.maardanzonderditstuk.nl> wrote:
> > I need to search a table and find a specific record. This I can do,
> > altho I then need to find 49 people either side of this record when
> > ordered by rank.

>
> > I.e I have loads of people who are ranked. Want to choose a player and
> > then find the people either side of that player.

>
> Sounds like a job for the HANDLER statement:
>
> http://dev.mysql.com/doc/refman/5.1/en/handler.html
>
> Best regards,
> --
> Willem Bogaerts
>
> Application smith
> Kratz B.V.http://www.kratz.nl/


I never even heard of the HANDLER! Definitely looks worth getting
into...
A long, long time ago I had a stab at doing something this, using a
bit of php to determine the limits.
My solution varied the resultset according to where in the overall
rankings the specified row appeared, so if the top ranked row was
selected it would show that and n succeeding rows, the bottom ranked
row would show n preceeding values, and a row somewhere in the middle
would show 1/2n rows either side.

See
http://groups.google.com/group/comp....aa58773be074e8

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 10:02 AM
Iain Adams
 
Posts: n/a
Default Re: Find records either side of the record found

On 15 Jun, 13:21, Willem Bogaerts
<w.bogae...@kratz.maardanzonderditstuk.nl> wrote:
> > I need to search a table and find a specific record. This I can do,
> > altho I then need to find 49 people either side of this record when
> > ordered by rank.

>
> > I.e I have loads of people who are ranked. Want to choose a player and
> > then find the people either side of that player.

>
> Sounds like a job for the HANDLER statement:
>
> http://dev.mysql.com/doc/refman/5.1/en/handler.html
>
> Best regards,
> --
> Willem Bogaerts
>
> Application smith
> Kratz B.V.http://www.kratz.nl/


I have been trying this Handler thing and am getting some results. But
I can only achieve what I want by doing 2 statement and then
concatenating the results using PHP. Is is possible to do a JOIN on
two HANDLER statements. I have tried but seem to be getting errors. Is
this possible or is it just my syntax wrong.

Also thanks strawberry, I had never heard of the handler either but it
seems fairly good.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 10:03 AM
lark
 
Posts: n/a
Default Re: Find records either side of the record found

Willem Bogaerts wrote:
>> I need to search a table and find a specific record. This I can do,
>> altho I then need to find 49 people either side of this record when
>> ordered by rank.
>>
>> I.e I have loads of people who are ranked. Want to choose a player and
>> then find the people either side of that player.

>
> Sounds like a job for the HANDLER statement:
>
> http://dev.mysql.com/doc/refman/5.1/en/handler.html
>
> Best regards,



indeed, very interesting. thanks for mentioning it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:08 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com