Hi,
Please find the below example.
sqlite> create table test (id integer primary key autoincrement, name text);
sqlite> insert into test (name) values('a');
sqlite> insert into test (name) values('a');
sqlite> select count(*) from test;
7
sqlite> select * from test limit 10 offset 2;
2|a
3|a
4|a
5|a
6|a
7|a
sqlite> select * from test limit 10 offset 5;
2|a
3|a
4|a
5|a
6|a
7|a
sqlite> select * from test limit 2 offset 5;
2|a
3|a
sqlite> select * from test limit 5,3;
2|a
3|a
4|a
sqlite> EXPLAIN SELECT * FROM test LIMIT 2 OFFSET 5;
addr opcode p1 p2 p3 p4 p5 comment
---- ------------- ---- ---- ---- ------------- -- -------------
0 Init 0 14 0 00
1 Integer 2 1 0 00
2 Integer 5 2 0 00
3 MustBeInt 2 0 0 00
4 OffsetLimit 1 3 2 00
5 OpenRead 0 383 0 2 00
6 Rewind 0 13 0 00
7 IfPos 2 12 1 00
8 Rowid 0 4 0 00
9 Column 0 1 5 00
10 ResultRow 4 2 0 00
11 DecrJumpZero 1 13 0 00
12 Next 0 7 0 01
13 Halt 0 0 0 00
14 Transaction 0 0 44 0 01
15 Goto 0 1 0 00
sqlite>
sqlite> .schema test
CREATE TABLE test (id integer primary key autoincrement, name text);
sqlite> PRAGMA table_info(test);
0|id|integer|0||1
1|name|text|0||0
sqlite>
Thanks,
Sathish
On Wed, May 16, 2018 at 3:43 PM, Richard Hipp <[email protected]> wrote:
> On 5/16/18, Sathish Kumar <[email protected]> wrote:
> > Hi All,
> > OFFSET clause is not working as expected in android platform.
> >
> > [ ISSUE ] : eg. select * from test limit 2 offset 5;
> >
> > [ Expected Result ] : This query should return two rows starting from
> index
> > 6.
> >
> > [ Actual Result ] : It always returns rows starting from index 2, even
> > though it had enough rows in the table. (Please see the below example, it
> > has all the informations).
>
> Unable to reproduce the problem. The example text came through garbled.
>
> --
> D. Richard Hipp
> [email protected]
>
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users