SQLite Forum

What is the recommended way to update multiple columns from a single select?
Login
Why all the complication in the first update.

```
update MyTable as dst
   set val_a = src.val_a,
       val_b = src.val_b,
       val_c = src.val_c
  from MyTable as src
 where src.object_id == dst.object_id
   and dst.snapshot_id == 2
   and src.snapshot_id == 1
;
```

It is pretty much a direct translation from English into SQL.

For number 2 a better method (if you are using an old version of SQLite3 that does not have UPDATE FROM) would be:

```
update MyTable as dst
   set (val_a, val_b, val_c) = (select val_a, val_b, val_c from MyTable where object_id == dst.object_id and snapshot_id == 1)
 where snapshot_id == 2
;
```

You would only need to use multiple correlated subqueries for really ancient versions of SQLite3 that does not have row-tuples.