gpt4 book ai didi

mysql - 如何从另一个表的 2 个变量更新一个表?

转载 作者:行者123 更新时间:2023-11-29 11:01:14 25 4
gpt4 key购买 nike

我有 2 个表,在表 A 中我有 id_Aregion_A,在表 2 中我有 id_B > 和 region_B

id_A 等于 id_B 时,我想设置 region_A = Region_B

我读到this question

并尝试过:

UPDATE  A  SET  A.`region` =   B.region  
FROM A
inner join B on A.id_a = B.id_b

我收到这个错误

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT * FROM A inner join B on A.id_a' at line 1

如何更新我的表 A?

最佳答案

这是 SQL Server 语法。试试这个:

UPDATE Α AS t1
INNER JOIN Β AS t2
ON t1.region = t2.region
SET t1.id_a = t2.id_b

关于mysql - 如何从另一个表的 2 个变量更新一个表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42208732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com