Question is relevant only to SQLite3. How to update a table row from another table?
My example:
Table “cashpoints” has columns “id”, “bank_id”
Table “banks_cashpoints” has columns “cp_id”, “b_id”
Tables should be joined by condition
cashpoints.id = banks_cashpoints.cp_id
So I need: banks_cashpoints.b_id -> cashpoints.bank_id
Each of my attempts failed. For example this (ERROR: near “from”: syntax error):
UPDATE cashpoints
SET bank_id = b_id
FROM banks_cashpoints bc
WHERE cp_id = id
As I read here, it’s not possible to use FROM statement is update query. But I have no idea how to do this without it.
Not sure if it works, but it’s worth trying: