我们有两个表table1 table2
In table1
Itemnumber SalesCode
123 213UB
142 132NB
1458 256GD
In table2
Itemnumber ProductGroupCode
123
142
1458
更新表2之后,我们需要这样
Itemnumber ProductGroupCode
123 213UB
142 132NB
1458 256GD
我们这样尝试过
tx.executeSql('UPDATE table2 JOIN table1 ON (table2.ItemNumber=table1.ItemNumber) SET table2.CustomerPriceGroup = table1.SalesCode');
但是我们有这样的错误
Colud not prepare Statement (Near "JOIN ":syntax error)
请告诉我我的代码有什么问题
SQLite不支持UPDATE语句中的JOIN。
您可以使用以下子查询来达到相同的结果
UPDATE table2
SET table2.CustomerPriceGroup =
(SELECT table1.SalesCode FROM table1 WHERE table2.ItemNumber=table1.ItemNumber)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句