Re: [sqlite] can you select series with SQL?

2011-11-20 Thread Bart Smissaert
I am not not working that close to the SQLite source to talk about sqlite3_step etc. as I am using a VB wrapper. Still, I suppose what you say still applies. As it turns out and can now beforehand (without checking for non-consecutive id numbers) how many records should be fetched, so with that

Re: [sqlite] can you select series with SQL?

2011-11-20 Thread Igor Tandetnik
Bart Smissaert wrote: > In fact when doing something as you suggest: > select * from MyTable where ID <= 14 order by ID desc > I can make it a lot more efficient by adding a limit as not many > records will be needed. There's no difference between adding a LIMIT N

Re: [sqlite] can you select series with SQL?

2011-11-20 Thread Bart Smissaert
Thanks; that to me looks a truly amazing SQL! As you say doing this in code might be more efficient and definitely less confusing. In fact when doing something as you suggest: select * from MyTable where ID <= 14 order by ID desc I can make it a lot more efficient by adding a limit as not many

Re: [sqlite] can you select series with SQL?

2011-11-19 Thread Jean-Christophe Deschamps
> so the consecutive numbers, going down from 14? Sorry I interpreted the question in a dumb way. Igor is certainly right (as usual). ___ sqlite-users mailing list sqlite-users@sqlite.org

Re: [sqlite] can you select series with SQL?

2011-11-19 Thread Igor Tandetnik
Bart Smissaert wrote: > If we have the 14 (we know to start at 14) can we select the records > 14, 13, 12 and 11, > so the consecutive numbers, going down from 14? select * from MyTable t1 where (select count(*) from MyTable t2 where t2.ID between t1.ID and 14) == 14 -

Re: [sqlite] can you select series with SQL?

2011-11-19 Thread Jean-Christophe Deschamps
ID 1 2 3 4 11 12 13 14 If we have the 14 (we know to start at 14) can we select the records 14, 13, 12 and 11, so the consecutive numbers, going down from 14? Sure: select id from yourtable where id <= 14 limit 4 order by id desc;

[sqlite] can you select series with SQL?

2011-11-19 Thread Bart Smissaert
Say we have a table table1 with unique integer field ID. Now we have the following data: ID 1 2 3 4 11 12 13 14 If we have the 14 (we know to start at 14) can we select the records 14, 13, 12 and 11, so the consecutive numbers, going down from 14? RBS