gpt4 book ai didi

mysql - 根据 MySQL 中连接的结果更新表

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

我理解这里的语法:

UPDATE table
SET column1 = expression1,
column2 = expression2,
...
WHERE conditions;

这里:

UPDATE table1
SET column1 = (SELECT expression1
FROM table2
WHERE conditions)
WHERE conditions;

...但是如果我想更新怎么办

UPDATE table1
SET column1 = expression
if we get a particular result on a join between table1 and table2
which has WHERE conditions?

我似乎无法弄清楚,而且我在所有尝试中都遇到了语法错误。非常感谢任何建议。

最佳答案

MySQL 的语法是:

UPDATE table1 JOIN
table2
ON conditions
SET table1.column1 = table2.expression1
WHERE conditions;

关于mysql - 根据 MySQL 中连接的结果更新表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33427523/

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