RE: [sqlite] How to get row numbers in a query?

2005-05-19 Thread Thomas Briggs
> Sorry, didn't mean to imply it wouldn't. You added this caveat though: > > > Note however that this really only does what you want when > tableB is initially empty Yeah, that's fairly easy to work around though. Assuming you know the structure of the ultimate destination table, which

Re: [sqlite] How to get row numbers in a query?

2005-05-19 Thread Jay Sprenkle
> >Out of curiosity, why doesn't the idea I proposed work? If there's a > situation where it doesn't work I'd like to know, so I don't try using > it myself should a similar situation arise. :) Sorry, didn't mean to imply it wouldn't. You added this caveat though: > Note however that this

RE: [sqlite] How to get row numbers in a query?

2005-05-19 Thread Thomas Briggs
Thursday, May 19, 2005 11:52 AM > To: sqlite-users@sqlite.org > Subject: RE: [sqlite] How to get row numbers in a query? > > So I guess I have to write my own function, "current_row()", using the > sqlite3_create_function() APIs? > > -Dave > > -Original Me

Re: [sqlite] How to get row numbers in a query?

2005-05-19 Thread Jay Sprenkle
> So I guess I have to write my own function, "current_row()", using the > sqlite3_create_function() APIs? If you've got a program handling this why don't you just count them as you retrieve them?

RE: [sqlite] How to get row numbers in a query?

2005-05-19 Thread Brown, Dave
So I guess I have to write my own function, "current_row()", using the sqlite3_create_function() APIs? -Dave -Original Message- From: Jay Sprenkle [mailto:[EMAIL PROTECTED] Sent: Thursday, May 19, 2005 8:40 AM To: sqlite-users@sqlite.org Subject: Re: [sqlite] How to get r

Re: [sqlite] How to get row numbers in a query?

2005-05-19 Thread Jay Sprenkle
> >Are you sure this is true? The rowid in the source table has no > relationship to the order of the results of the query. You're right. I thought it was the row number of the result set, it's not: D:\temp\convention>sqlite3 test.db SQLite version 3.0.8 Enter ".help" for instructions

Re: [sqlite] How to get row numbers in a query?

2005-05-19 Thread Jay Sprenkle
> Is there any way to SELECT out the row number of returned results in a > query? > For example: > > SELECT row_number(), value from some_table; > 1 ValueA > 2 ValueB > 3 ValueC > ... etc ... ?? > > What I really want this for is a query where I am inserting from table A > into table B, and

RE: [sqlite] How to get row numbers in a query?

2005-05-19 Thread Thomas Briggs
If you create your Ordering column in table B as type INTEGER PRIMARY KEY, you can do: INSERT INTO tableB (value) SELECT value FROM tableA ORDER BY ... And when you're done, the value of tableB.Ordering will represent the order in which the rows were inserted into the

Re: [sqlite] How to get row numbers in a query?

2005-05-19 Thread Paolo Vernazza
Brown, Dave wrote: Is there any way to SELECT out the row number of returned results in a [...] I want this to result in the following being added to tableB: Value | Ordering 5 1 8 2 9 3 etc Any ideas? -Dave I think you should register a new functions