I need to find the next record in a database with (say) a given Surname. So if the user is looking at A Smith, the query would return either the Next A Smith, or B Smith
the solution is probably similar to that discussed here : http://stackoverflow.com/questions/638065/selecting-subsequent-records-arbitrarily-with-limit but using an ODBC 2.0 compliant database rather than mysql.
At the moment I have a procedural solution, but it is very slow. Is there a more elegant approach which uses only basic SQL ?
Sample Data in "appropriate" order
recnum, surname, firstnames 1000,smith,andrew 1320,smith,andrew 1340,smith,andrew 14,smith,anton 17,smith,anton 2000,smith,brian 2030,smith,brian 1017,smith,brianally
I would have the recnum of the current record and need to find the next in the above (which is ordered on surname, forenames, recnum) In this example the case for 1320 is easy, but 1340 makes it harder!