|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
index retrieval
this is probably a dumb question but ...
I want to retrieve the index sequence of a field - preferably without retrieving the whole table so if I have a data item called score which is indexed and contains a numeric value, I want to know it is say the 5th highest in the table. I can do a ORDER by score DESC, but this is going to retrieve the whole table. Is there a way to retrieve the sequence directly from the index ? thanks .. Mike |
|
#2
|
||||
|
||||
|
SELECT score FROM table ORDER BY score DESC LIMIT 5
Note, you can pick and choose your fields, instead of doing SELECT * you can do SELECT field1, field2, etc... |
|
#3
|
|||
|
|||
|
clarification
thanks - but I need to clarify
5th was just an example - I dont know the ranking for each record which means I need to read the whole table in score sequence until I find the sequence for this record ? as I do this a lot - I am looking for a way to optimise the retrieval. Mike |
|
#4
|
||||
|
||||
|
__________________
This is my code. Is it not nifty? "The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools." ---Douglas Adams Join the Itsacon fanclub! Zero Tolerance: Spammers banned so far: 264
![]() |
|
#5
|
|||||
|
|||||
|
So what you actually want is a way to retrieve the rank of a know item?
try this: mysql Code:
Where "id = 'wantedid' can be replaced by anything that identifies the record you want the ranking for. |
|
#6
|
|||
|
|||
|
Thanks
thanks itsacon - thats very helpful
|
|
#7
|
||||
|
||||
|
Good. that was my intention
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > index retrieval |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|