Re: [sqlite] Getting a rowid from a view

2010-06-01 Thread Pavel Ivanov
A bit of bitterness here: Jim, do you know that SELECT doesn't guarantee rows to be returned in any particular order unless ORDER BY clause is used? It's even not guaranteed that the same SELECT without ORDER BY issued twice will return rows in the same order. So when you do SELECT * FROM

Re: [sqlite] Getting a rowid from a view

2010-05-30 Thread Kit
2010/5/29 Jim Terman jter...@tivo.com: 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

Re: [sqlite] Getting a rowid from a view

2010-05-29 Thread Kees Nuyt
On Fri, 28 May 2010 17:19:37 -0700, Jim Terman jter...@tivo.com wrote: 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,

Re: [sqlite] Getting a rowid from a view

2010-05-29 Thread Kees Nuyt
On Sat, 29 May 2010 02:35:22 +0100, Simon Slavin slav...@bigfraud.org wrote: On 29 May 2010, at 2:30am, Jim Terman wrote: I want the 'rowid' of the view. In other words I'd like to now what row John Smith is in the view. I can do it with a view that is ordered by using count(*), but I

Re: [sqlite] Getting a rowid from a view

2010-05-29 Thread Kees Nuyt
On Fri, 28 May 2010 17:19:37 -0700, Jim Terman jter...@tivo.com wrote: SELECT rowid FROM phonebook where last_name = Smith and first_name = John; By the way, string literals (text) in SQL should be delimited by single quotes, not double quotes. Double quotes are used to allow reserved words

[sqlite] Getting a rowid from a view

2010-05-28 Thread Jim Terman
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

Re: [sqlite] Getting a rowid from a view

2010-05-28 Thread Simon Slavin
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;

Re: [sqlite] Getting a rowid from a view

2010-05-28 Thread Jim Terman
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:

Re: [sqlite] Getting a rowid from a view

2010-05-28 Thread Simon Slavin
On 29 May 2010, at 1:44am, Jim Terman wrote: 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. When you do your

Re: [sqlite] Getting a rowid from a view

2010-05-28 Thread Jim Terman
I want the 'rowid' of the view. In other words I'd like to now what row John Smith is in the view. I can do it with a view that is ordered by using count(*), but I wondered if there was a better way. Simon Slavin wrote: Or are you asking about the 'rowid' of the view ? I don't know whether

Re: [sqlite] Getting a rowid from a view

2010-05-28 Thread Simon Slavin
On 29 May 2010, at 2:30am, Jim Terman wrote: I want the 'rowid' of the view. In other words I'd like to now what row John Smith is in the view. I can do it with a view that is ordered by using count(*), but I wondered if there was a better way. I believe that a view is just a window into