How do I make an UPDATE while joining tables on SQLite? How do I make an UPDATE while joining tables on SQLite? sqlite sqlite

How do I make an UPDATE while joining tables on SQLite?


You can't. SQLite doesn't support JOINs in UPDATE statements.

But, you can probably do this with a subquery instead:

UPDATE closure SET checked = 0 WHERE item_id IN (SELECT id FROM item WHERE ancestor_id = 1);

Or something like that; it's not clear exactly what your schema is.


You can also use REPLACE then you can use selection with joins.Like this:

REPLACE INTO clusure  SELECT sel.col1,sel.col2,....,sel.checked --checked should correspond to column that you want to changeFROM ( SELECT *,0 as checked FROM closure LEFT JOIN item ON (item_id = id)  WHERE ancestor_id = 1) sel