2013-04-07 69 views
0

我有以下SQL查询时:MySQL错误1064更新多个列

UPDATE mytable SET status = '2', dec = '268435458001932988' WHERE id = 29952 

表:

status = varchar(1) 
dec = varchar(23) 

后我在手动读取,我可以用分隔条件他们更新多列” ”。

那么为什么我在这里得到语法错误(1064)?

#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 'dec = '268435458001932988' WHERE id = 29952' at line 1 
+0

是否有'id'列? – Aiias 2013-04-07 20:26:19

+0

是的,当我删除“,dec ='268435458001932988'”它工作正常 – 2013-04-07 20:26:55

回答

3

DEC显然是MySQL中的一个保留字。使用反引号。

UPDATE Mytable SET status = '2', `dec` = 'etc.'... 

的保留字列表:https://dev.mysql.com/doc/refman/4.1/en/reserved-words.html

+1

argh ...(headbang)...谢谢...现在工作...他们应该真的更新错误信息:D – 2013-04-07 20:28:41

+1

@MichaelGrenzer I不能说我不同意... MySQL是相当臭名昭着的错误消息 – 2013-04-07 20:29:11

+1

,这让我头痛3个小时..大声笑。我应该给他们发一张阿司匹林的发票...会在几分钟内接受..再次感谢。 – 2013-04-07 20:31:06

2

dec是一个保留字(简写decimal)。尝试用反引号引用dec标识符:

update mytable set status ='2',`dec` ='268435458001932988'其中id = 29952;

1

试试这个

UPDATE mytable SET status = '2', `dec` = '268435458001932988' WHERE id = 29952 

DEC保留关键字为MySQL。