In fact, in MySQL, multi-table joint update is not difficult.
Grammar:
UPDATE SET col_name1=[, COL_NAME2=EXPR2 ... ][WHERE where_definition]
Example:
UPDATE SET table1.value=Table2.value, a.type=WHERE table1.sid=
Similarly, in SQL Server, it is possible to use federation as a simple implementation:
UPDATE SET col1=fromINNERJOIN on t1.col2=
However, unfortunately, in SQLite does not support such a syntax, it is not in SQLite does not support multi-table joint update it? Of course not, in fact, SQLite in the multi-table joint update can also be achieved,
First of all, SQLite has a fresh thing "INSERT OR REPLACE", similar to MySQL, this structure can be guaranteed to be replaced in the presence of the situation, the non-existent situation of the update, with this mechanism can easily implement the update ... From the.
INSERT OR REPLACE into T1 (keySELECT T2. KeyfromWHERE T2. Key = T1. Key
This approach avoids insertions, first ensuring that updates are performed according to the primary key, which can be a bit cumbersome if the where condition is not the primary key.
Do you want to update the primary key? Is there another way to do it? We can only ask the typical update...where for help in this case, here is an example:
UPDATE SET = 1 WHERE = (SELECTfromWHERE=and=5
Go SQLite Data Multi-table federated update