If you do a select with the an ORDER BY ... DESC (or ASC) LIMIT 1, with the order-by clause matching one of the indexes on that table, then you'll get the last row without having to use a rowid.
For example: CREATE TABLE person (firstname TEXT, lastname TEXT, stuff TEXT, PRIMARY KEY (lastname, firstname)) WITHOUT ROWID; -- insert some rows -- efficiently select the last cursor SELECT * from person ORDER BY lastname DESC, firstname DESC LIMIT 1; Traversing from end to start is easy: drop the LIMIT. The same applies to going back one, but you need to add a WHERE clause (you want rows with smaller index key than the current row). When using primary this is all very efficient, but NOT as efficient as when you have a low-level cursor and can move it around at the low-level b-tree (or whatever) interface. Nico -- _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users