【发布时间】:2016-04-02 21:48:31
【问题描述】:
如何在 python 上的 sql lite 中使用另一个表中的值更新表列。
例子,
表1
id name value brand
1 n1 v1 -
2 n2 v2 -
表2
id brand
1 b1
我想更新 table1 品牌 = b1 for id=1
我正在尝试这样做
UPDATE table1 r join table2 p on r.id= p.id set r.brand=p.brand
但是python在执行这个语句时会抛出错误
sqlite3.OperationalError: near "r": syntax error
请提供任何解决方案
【问题讨论】:
-
UPDATE table1 SET table1.brand = (SELECT table2.brand FROM table2 WHERE table2.id = table1.id)? stackoverflow.com/questions/3845718/… -
它不起作用。 sqlite3.OperationalError:靠近“。”:语法错误
标签: sqlite sql-update