问题
I want to do exactly what it was described in this question: (Copy Column Value from One table into Another Matching IDs), but in SQLite instead of MySQL.
The solution provided:
update t1, t2 set t1.value = t2.p_value where t1.id=t2.parent_id
returns an error near ","... If I say
update t1 set t1.value = t2.p_value where t1.id=t2.parent_id
returns an error near "."
I was not expecting the syntax of MySQL being so different from SQLite.
回答1:
You could try
UPDATE t1
SET t1.value = (
SELECT t2.p_value
FROM t2
WHERE t1.id = t2.parent_id)
or using you code try
UPDATE t1
SET value = (
SELECT value
FROM t2
WHERE t1.id = t2.id)
来源:https://stackoverflow.com/questions/57414183/copy-column-value-from-one-table-into-another-matching-ids-sqlite