gpt4 book ai didi

mysql - 关于重复键 - 更新多个表

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

如何通过插入更新多个表?我在这里尝试的方法不起作用。另外,如何用投票变量和现有 v.weight 之间的差异添加/减去 u.score

INSERT INTO votes (userid, publication_id, weight) VALUES (1,2,3)
ON DUPLICATE KEY
UPDATE votes v, users u


SET v.weight=1
WHERE v.userid=1
--TODO: update u.score

最佳答案

听起来您可能想使用触发器:

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

或者,您可以将初始插入、逻辑以及任何后续插入封装到存储过程中:

http://dev.mysql.com/doc/refman/5.0/en/stored-routines.html

关于mysql - 关于重复键 - 更新多个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8612741/

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