You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
UPDATE and DELETE with an IN subquery reuse the subquery result of the first run on later runs #3137
alasql('CREATE TABLE u (x INT); INSERT INTO u VALUES (1),(2)');alasql('CREATE TABLE t (a INT, b INT); INSERT INTO t VALUES (1,0),(2,0),(3,0)');constupd='UPDATE t SET b = b + 1 WHERE a IN (SELECT x FROM u WHERE x <= ?)';alasql(upd,[1]);alasql(upd,[2]);alasql('CREATE TABLE d (a INT); INSERT INTO d VALUES (1),(2),(3)');constdel='DELETE FROM d WHERE a IN (SELECT x FROM u WHERE x <= ?)';alasql(del,[1]);alasql(del,[2]);alasql('SELECT * FROM t; SELECT * FROM d');
The second UPDATE changes 1 row and the second DELETE deletes none, so t is (1, 2), (2, 0), (3, 0) and d is 2, 3.
SQLite changes 2 rows and deletes 1 row, so t is (1, 2), (2, 1), (3, 0) and d is 3.
Activity