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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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. |
| |||
| > 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/ |
| |||
| 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 |
| |||
| 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. |
| ||||
| 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. |
| Thread Tools | |
| Display Modes | |
|
|