On 8/6/17 4:03 PM, Edmondo Borasio wrote:
*progr_no* *ID*
1 grace
*2* *john*
3 alan
4 tim
*5* *john*
*6* *john*
7 sandra
*8* *john*
What is the simplest and most efficient way of telling SQLITE to select the
NEXT or the PREVIOUS *progr_no *for a given recurring ID, let's say "john"?
Let's assume that I currently I am at progr_no=5.
I was thinking of maybe looping for a given ID and building an associative
array with also the progr_no, but there must be a more efficient and direct
solution, I guess!
Cheers
Ed
Something like SELECT progr_no FROM table WHERE progr_no > 5 AND ID =
"john" ORDER BY progr_no ASC LIMIT 1
(I think that's correct, doing strictly from memory).
Not sure what the best index would be, probably an index on ID, progr_no
since ID needs an exact match
--
Richard Damon
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users