Say I have a table of phone numbers

CREATE TABLE phonebook (first_name TEXT, last_name TEXT, phone_number TEXT);

I want to sort this by name, so I create a view

CREATE VIEW phonebook_order AS SELECT first_name, last_name, 
phone_number FROM phonebook ORDER BY last_name, first_name;

Now on the table phonebook I can do a query:

SELECT rowid FROM phonebook where last_name = "Smith" and first_name = 
"John";

which will gave me the row number of John Smith.

How do I do this for the view phonebook_order?

Nearest I can determine would be to run the command

SELECT COUNT(*) from phonebook_order WHERE last_name <= "Smith" AND 
first_name <= "John";

Is there an easier way?
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to