SQL错误,我不明白

标签 sql mysql mysql-error-1064

INSERT INTO `tims`.`pending_profile`(`id`, `nickname`, `location`, `role`, `yog`, `interests`, `favMoment`, `gainThisYr`, `futurePlans`, `bio`) 
VALUES ('1', '1', '1', '1', '', '1', '1', '1', '1', '1')
ON DUPLICATE KEY UPDATE ( nickname ='1', location= '1', role= '1',yog= '1',interests= '1',favMoment= '1',gainThisYr= '1',futurePlans= '1',bio= '1')

是什么触发了这个错误?

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 '( nickname ='1', location= '1', role= '1',yog= '1',interests= '1',favMoment= '1'' at line 3

最佳答案

在字段之间放置逗号:

INSERT INTO tims.pending_profile
  (id, nickname, location, role, yog, interests, favMoment, gainThisYr, futurePlans, bio) 
VALUES
  ('', '1', '1', '1', '', '1', '1', '1', '1', '1')
ON DUPLICATE KEY UPDATE nickname ='1', location= '1', role= '1', yog= '1', interests= '1', favMoment= '1', gainThisYr= '1', futurePlans= '1', bio= '1'

关于SQL错误,我不明白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3560379/

相关文章:

php - 不知道为什么这个登录脚本不起作用!

php - 如果 mysql_query 不成功则显示错误

php - MySQL 错误 : ' You have an error in your SQL syntax'

Java SQL : use previously existing result sets

mysql - 在 MySQL 中按 DATE 分组 DATETIME 并显示当天的最后一条记录

Java:如何插入N:M关联表

php - MySQL:是否可以缩短错误消息?

mysql - 加速MYSQL LIKE '%word%'语句

java - 如何在 Android 中使用多个数据库帮助程序类在 SQLite 中进行内部联接

mysql - 为什么我的正则表达式不返回正确答案?