gpt4 book ai didi

mysql - 我可以用一个查询更新两个相同的表吗 - MySQL

转载 作者:行者123 更新时间:2023-11-29 04:13:45 29 4
gpt4 key购买 nike

我可以用一个查询更新两个相同的表吗?

TABLEA
_____________________________
| id | value |
|_____________|_____________|
| 1 | a |
| 2 | b |
| 3 | c |
| 4 | d |
| 5 | e |
|_____________|_____________|

TABLEB
_____________________________
| id | value |
|_____________|_____________|
| 1 | a |
| 2 | b |
| 3 | c |
| 4 | d |
| 5 | e |
|_____________|_____________|

我想同时更新两个表(SET value = 'z' WHERE id=3)。这可能吗?

-谢谢

最佳答案

通过阅读 mysql update reference,它说:

For the multiple-table syntax, UPDATE updates rows in each table named in table_references that satisfy the conditions. In this case, ORDER BY and LIMIT cannot be used.

UPDATE items,month SET items.price=month.price WHERE items.id=month.id;

http://dev.mysql.com/doc/refman/5.0/en/update.html

关于mysql - 我可以用一个查询更新两个相同的表吗 - MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3354507/

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