Colin Manning <[EMAIL PROTECTED]> wrote:
Then assume I'm writing an app that displays the entire directory in a
window, ordered by name/number etc using a scrollbar to move up and
down.
So I might have:
CREATE TABLE pb (id INT, name VARCHAR(40),...);
CREATE INDEX pb_idx_name ON pb(name);
..

Not a problem. I can use "SELECT * FROM pb ORDER BY name LIMIT x,y"
etc as my user pages up and down the list, or drags a scrollbar.

Next, assume the user wants to jump to a specific record in the list,
or to (say) the first entry for a specific name.

How do you do this with sqlite, without forcing the the app to fetch
every record and then do a manual comparison in the app?

select * from pb where name>='Specific Name' ORDER BY name LIMIT x,y;

E.g. my user wants the app's window to 'jump' to the first record
with name 'John Smith'. I.e what my windowed app wants to do is to
find the 'position' x of the first record in the name index that
matches 'John Smith',

select count(*) from pb where name < 'John Smith';

Igor Tandetnik

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to