SQLite 多表关联更新
更新多字段
UPDATE tab1
SET field1 = field1 || '-',
field2 = field2 + 1
WHERE ID < 10
或
UPDATE tab1
SET (field1, field2) = (field1 || '-', field2 + 1)
WHERE ID < 10
关联更新
普通方式
UPDATE tab1
SET field1 = (SELECT tab2.field3 FROM tab2 WHERE tab2.FID = tab1.ID),
WHERE EXISTS (SELECT * FROM tab2 WHERE tab2.FID = tab1.ID)
或
UPDATE tab1
SET (field1, field2) = (SELECT tab2.field3, tab2.field4 FROM tab2 WHERE tab2.FID = tab1.ID)
WHERE EXISTS (SELECT * FROM tab2 WHERE tab2.FID = tab1.ID)
UPDATE FROM 方式
UPDATE tab1
SET field1 = t.zd3
FROM (SELECT sum(field3) AS zd3, FID FROM tab2 GROUP BY FID) AS t
WHERE ID = t.FID;