Hello, first let me mention that I am new to this list so apologies if my question came up before. I couldn't find anything though, and in #sqlite on Freenode I was pointed here, so here I am.
I am working on some code that creates a (potentially big) SQL query on the fly. My problem is, that I need to get a certain subset of the result the query gives. However, that somehow doesn't work with sqlite 3.14.2. In 3.8.5 it still worked according to someone on IRC testing it. Example database: sqlite> .dump i PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE i (id integer primary key autoincrement, flags integer); INSERT INTO "i" VALUES(1,1); INSERT INTO "i" VALUES(2,1); INSERT INTO "i" VALUES(3,1); INSERT INTO "i" VALUES(4,1); INSERT INTO "i" VALUES(5,5); INSERT INTO "i" VALUES(6,6); INSERT INTO "i" VALUES(7,4); COMMIT; sqlite> .dump m PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE m (id integer); INSERT INTO "m" VALUES(1); INSERT INTO "m" VALUES(2); INSERT INTO "m" VALUES(3); INSERT INTO "m" VALUES(4); INSERT INTO "m" VALUES(5); INSERT INTO "m" VALUES(6); INSERT INTO "m" VALUES(7); COMMIT; Simplified example query – in reality there would be a couple of those inner SELECT which makes it hard to use JOIN. sqlite> SELECT id FROM i WHERE id IN (SELECT id FROM m) ORDER BY flags DESC; 6 5 7 1 2 3 4 Now I only want the first three values, 6, 5 and 7. However: sqlite> SELECT id FROM i WHERE id IN (SELECT id FROM m) ORDER BY flags DESC LIMIT 0, 3; 1 2 3 It almost seems to limit the inner SELECT instead of the outer one. Is that a bug in recent versions of sqlite? Or was that a bug before and I am doing something wrong? Thanks for any insight and maybe a hint how to get what I want Tobias
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users