Updated multi-table associated UPDATE statement for SQLite database, which is a little bit different from other databases
For example: In SQL Server:
Assign the value of the Table2 num field to the Table1 num field with the Table1 ID and the table2 PID, associated table1, and table2
Set num1 = t2.num2
On T1.id=t2.pid;
It's easy to link up.
SQLite does not support this association, so you can:
(1) Set, to assign the value of the Table2 num2 to the Num1 field of table1, select Table2 and associate with parentheses
Update Table1set num1 = (select num2 from table2 where table2.pid=table1.id)
where ...
When updating multiple fields:
Update Table1set num1 = (select num2 from table2 where table2.pid=table1.id), Num11 = (select Num22 from table2 where T Able2.pid=table1.id) where ...
(2) where is the same, for example, I will change the above
Update table1set num = 99where table1.id= (select PID from table2 where Table2.pid=table1.id)
SQLite Multi-table associated update