SQL 语法错误;重复键更新
error in your SQL syntax;ON DUPLICATE KEY UPDATE
在 MySQL 5.6
上尝试以下命令但出现语法错误。
INSERT INTO device
( uid, name, type, os, device_active,
screen_resolution, network_type,status)
VALUES ('1110b','XIAOMI','Android','Android 10',
false,'2340*1080','WIFI',1),
('A2QD1','HUAWEI','Android','Android 7.0',
true,'1920*1080','WIFI',1) As new
ON DUPLICATE KEY
UPDATE device_active = VALUES(new.device_active);
Error: 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 'As new ON DUPLICATE KEY UPDATE device_active = VALUES(new.device_active)'
新。值仅在触发器中可用 VALUES(device_active) 应该足够了。
在 MySQL 5.6
上尝试以下命令但出现语法错误。
INSERT INTO device
( uid, name, type, os, device_active,
screen_resolution, network_type,status)
VALUES ('1110b','XIAOMI','Android','Android 10',
false,'2340*1080','WIFI',1),
('A2QD1','HUAWEI','Android','Android 7.0',
true,'1920*1080','WIFI',1) As new
ON DUPLICATE KEY
UPDATE device_active = VALUES(new.device_active);
Error: 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 'As new ON DUPLICATE KEY UPDATE device_active = VALUES(new.device_active)'
新。值仅在触发器中可用 VALUES(device_active) 应该足够了。