gpt4 book ai didi

php - 如何将重复键更新插入到mysql表中?

转载 作者:行者123 更新时间:2023-11-29 21:49:52 24 4
gpt4 key购买 nike

我有一个与另一个表相关的表。我需要插入 ids 并更新重复的键插入。下面是我插入表中但给出语法错误的查询。将像这样插入多行(88, 90709), (88, 90710), ..

 Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '90713), business_id= VALUES(88)' at line 3

INSERT INTO business_service_coverage (business_id, area_id) VALUES (88,90713) ON DUPLICATE KEY UPDATE area_id = VALUES(90713), business_id= VALUES(88)

表结构

 1) id  primary key auto increment
2) busienss_id not unique
3) area_id int

最佳答案

您的syntax指定的内容是错误的,请尝试以下操作

INSERT INTO business_service_coverage (business_id, area_id) VALUES (88,90713) 
ON DUPLICATE KEY UPDATE area_id = 90713, business_id= 88;

关于php - 如何将重复键更新插入到mysql表中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33753993/

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