gpt4 book ai didi

MYSQL 重复键更新问题

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

当重复的主键已经在表中时,我正在尝试使用“ON DUPLICATE KEY UPDATE”语句来更新列。但即使表有重复的主键,它也不会更新列。

下面是“ON DUPLICATE KEY UPDATE”声明。有什么问题吗?

 ON DUPLICATE KEY UPDATE authenticated = authenticated
and notAuthenticated = notAuthenticated
and stoped = stoped
and deleted = deleted
and updatedDate = now()

;

最佳答案

使用 VALUES(Column) 并将所有 AND 替换为逗号 ,:

 ON DUPLICATE KEY UPDATE authenticated = VALUES(authenticated),
notAuthenticated = VALUES(notAuthenticated),
stoped = VALUES(stoped),
deleted = VALUES(deleted),
updatedDate = now()

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

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