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
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
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
> 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
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 -
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;
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
7 matches
Mail list logo