On 14 Jul 2009, at 12:16am, Bogdan Nicula wrote: > Given a column containing numbers, which is the most efficient > manner to find out the highest smaller and lowest greater number? > That is, is there a better way than: > > select * from table where number <= ? order by number desc limit 1; > select * from table where number>= ? order by number asc limit 1;
Nope, that's a pretty good method. Except of course you need '>' not '>=' and '<' not '<='. Make sure, of course, that there's an index that starts with the 'number' field. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users