MySQL Forums
Forum List  »  Newbie

Re: Retrieving Next Row in Index
Posted by: Rick James
Date: January 15, 2015 10:25AM

Let's say you want the next one after name='abc':

SELECT ... FROM ...
WHERE name > 'abc'
ORDER BY name
LIMIT 1;

That works well for a non-compound, UNIQUE index.
For a compound index (eg, INDEX(last_name, first_name)), it is more complex.
For non-UNIQUE, the problem is non-deterministic, so clarify what you want.

Or you could use the "Handler" interface.

Options: ReplyQuote


Subject
Written By
Posted
January 13, 2015 02:55PM
Re: Retrieving Next Row in Index
January 15, 2015 10:25AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.