[英]MySQL - Replace Column Value
I want to update/replace two column's value in a time. 我想一次更新/替换两列的值。
UPDATE table_messages SET id_msg = 4, numbers_msg = 50;
and: 和:
INSERT INTO table_messages (number_msg, id_msg) VALUES (50, 4);
mysql said: #1062 - Duplicate entry '4' for key 'PRIMARY' mysql说:#1062-键“ PRIMARY”的条目“ 4”重复
both not working, what's the problem? 两者都不起作用,怎么了? any other command? 还有其他命令吗?
your id_msg
cant be duplicated because its primary key
. 您的id_msg
无法复制,因为它的primary key
。 you maybe interested to just update numbers_msg
. 您可能只想更新numbers_msg
。
like that: 像那样:
UPDATE table_messages SET numbers_msg = 50 WHERE id_msg = 4 ;
Or : 要么 :
delete old id_msg = 4 and then use your query. 删除旧的id_msg = 4,然后使用您的查询。
INSERT INTO table_messages (number_msg, id_msg) VALUES (50, 4);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.