Mysql 如何基于公共参数使用另一个表中的值更新一个表中的行
我有两张桌子Mysql 如何基于公共参数使用另一个表中的值更新一个表中的行,mysql,sql,sqlite,Mysql,Sql,Sqlite,我有两张桌子 Table A with the following columns Id title desc type Table B with the following columns Id type 我希望基本上更新表A中的所有行,在这些行中,我将使用具有相应相同类型的表B的Id值替换该类型 比如说 Table A can have 1 ,test1 ,ddd, play 2 ,test2 ,ddd2, go 3 ,test3 ,ddd3, play Table
Table A with the following columns
Id title desc type
Table B with the following columns
Id type
我希望基本上更新表A中的所有行,在这些行中,我将使用具有相应相同类型的表B的Id值替换该类型
比如说
Table A can have
1 ,test1 ,ddd, play
2 ,test2 ,ddd2, go
3 ,test3 ,ddd3, play
Table B has
1, play
2, go
所以我希望能够运行查询,使表A看起来像
1 ,test1 ,ddd, 1
2 ,test2 ,ddd2, 2
3 ,test3 ,ddd3, 1
如何在“SqlLite”查询中实现这一点?我一直得到“tA附近的错误”,是否SQLITE与MYSQL不同?我正在使用SQLLite我做了一个搜索,似乎SQLite不支持加入更新。我希望我错了,因为SQLite允许相关子查询。看,你的问题被标记了,所以我给出了答案。我不知道sqlite。可能是的副本
UPDATE tableA tA
JOIN tableB tB
ON tA.type = tB.type
SET tA.type = tB.Id