Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 如何基于公共参数使用另一个表中的值更新一个表中的行_Mysql_Sql_Sqlite - Fatal编程技术网

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