SQL错误,我不明白

时间:2010-08-24 19:39:17

标签: 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')

什么是触发此错误?

  

您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在'附近使用正确的语法'(nickname ='1',location ='1',role ='1',yog ='1',interests ='1',favMoment第3行='1'

3 个答案:

答案 0 :(得分:4)

在字段之间加上逗号:

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'

答案 1 :(得分:1)

您从未打开括号,并且字段之间需要逗号

ON DUPLICATE KEY UPDATE **(**nickname ='1', location= '1', role= '1', yog= '1', interests= '1', favMoment= '1', gainThisYr= '1', futurePlans= '1', bio= '1')     

答案 2 :(得分:1)

您是否应该使用逗号分隔要在最后一行更新的列列表?

相关问题