On Dec 22, 2008, at 6:18 PM, flakpit wrote:

>
>
>
> Dan Kennedy-4 wrote:
>>
>>
>>> Is there any way to fetch the very first record in the database and
>>> find the > id number?
>>
>> The 'first record' is a malleable concept. You can find the record  
>> with
>> the lowest rowid value with:
>>
>>   SELECT ... FROM <table> ORDER BY rowid LIMIT 1;
>>
>>
>
> Thank you, that worked.
>
> Two questions spring to mind however..
>
> 1.  How many records are processed by SQLITE to get you the lowest  
> rowid
> value this way, does it have any significant impact on memory?

Just 1. It's a very efficient query.

> 2. The above statement gets the lowest rowid but there appears to be  
> no
> implicit statement to the direction of the ORDER BY clause. Can the
> statement be reversed to get the highest rowid?

   SELECT ... FROM <table> ORDER BY rowid DESC LIMIT 1;

Details at:

   http://www.sqlite.org/lang_select.html


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

Reply via email to