Greetings All!
I have a database of people. They were not entered alphabetically.
I have a script that shows all data on one person. I'd like to create a "previous person" and a "next person" link on the page. Of course, these would be the next/previous persons ALPHABETICALLY.
So, yes, I was thinking I could just do a
SELECT * from person order by lastname, firstname
and then I could loop through, match on the person id for the one person we're editing on this page... and have the script locate the previous and next person id numbers.
However, this seems terribly inefficient.
Since I already have the person id of one individual... and I just want to get the person id's of the row before and the row after this person, once the people are all sorted alphabetically... isn't there a way to do this all in one select?
I'm not sure... as I was under the impression that MySQL does it's "order by" sorting AFTER it has fully completed the "select" portion of the statement.
Thanks!
-= Dave =-