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 row numbers in a query?

> 
>    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
sqlite> create table t1(
   ...>     Id                INTEGER PRIMARY KEY,
   ...>  value text );
sqlite> insert into t1(value) values('one'); insert into t1(value) 
sqlite> values('two'); insert into t1(value) values('three'); insert 
sqlite> into t1(value) values('four'); select * from t1;
1|one
2|two
3|three
4|four
sqlite> select rowid, value from t1 where id>2;
3|three
4|four
sqlite>

Dave, Looks like rowid gives you the order of insertion not the order of
retrieval.

Reply via email to