That's good to now about the automatic rowid. I can certainly create a 
new column in phonebook that shows the row number with id INTEGER 
PRIMARY KEY AUTOINCREMENT. However, I'd really would like to do the same 
thing in a view.

Simon Slavin wrote:
> On 29 May 2010, at 1:19am, Jim Terman wrote:
>
>   
>> 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?
>>     
>
> Never depend on a rowid field you do not create yourself.  Although you know 
> SQLite creates them internally do not depend on them.  So equip phonebook 
> with an explicit INTEGER PRIMARY KEY AUTOINCREMENT field called, perhaps, id 
> and use that where you want it.
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>   

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to