Nope - that just gets the one closest to the date I specified. Perhaps you meant to use "asc" instead of "desc", but that gets the oldest one in the list.

What I'm trying to do is get the timestamp of 100th (or less if there are less than 100 previous items) previous item in the list.

Thanks,

Liz.


----Original Message Follows---- From: Gerhard Häring <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: Re: [sqlite] How do I get the last item in a list. Date: Thu, 04 Dec 2003 15:58:41 +0100

Liz Steel wrote:
I'm doing a select on a table as follows, and I want to get the last item in the list. How can I do this without having to step through all of the previous items? This may or may not return 100 rows since I cannot be sure of the size of the data.

select * from tablename where timestamp < '2003/12/04 12:00:00:000' order by timestamp limit 100;

select * from tablename where timestamp < '2003/12/04 12:00:00:000' order by timestamp desc limit 1;

HTH,

-- Gerhard


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

_________________________________________________________________
Use MSN Messenger to send music and pics to your friends http://www.msn.co.uk/messenger



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to