2011-06-16 66 views
0

嘿傢伙我有問題與MySQL。奇怪的MySQL問題

即時通訊使用此查詢時,它會引發錯誤。

update table set column1 = 'test' where column2 = 'xy' and column3 = 'xx' 

的錯誤是:

#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 'column2 = 'xy' and column3 = 'xx'' at line 1 

我到底做錯了什麼?

乾杯。

+0

你得到什麼錯誤? – 2011-06-16 23:23:49

+2

如果你說出它引發了什麼錯誤,它會很酷。想象一下來到一家汽車商店,並說:「大家好,我的車壞了,怎麼回事?」。 – 2011-06-16 23:24:09

+0

#1064 - 您的SQL語法錯誤;檢查與您的MySQL服務器版本相對應的手冊,以便在第1行'column2 ='xy'和column3 ='xx''附近使用正確的語法^^這些僅僅是示例名稱 – king 2011-06-16 23:26:33

回答

2

您需要提供真實姓名和值以及真正的錯誤。你如何期待任何人來幫助你?

根據對@Will A的回答的評論,看起來column2是保留字。嘗試用蜱(`)包裝或寫tablename.columnname而不是columnname

+0

謝謝tablename.column工作.. .guess它是保留名稱或其他東西 乾杯 – king 2011-06-16 23:36:23

1

你的桌子叫做「桌子」嗎?試試:

update `table` set column1 = 'test' where column2 = 'xy' and column3 = 'xx' 

改爲。

+0

nope它不叫表只是示例 – king 2011-06-16 23:23:29

+0

#1064 - 你的SQL語法錯誤;檢查對應於您的MySQL服務器版本的手冊,以便在第1行'column2 ='xy'和column3 ='xx''附近使用正確的語法。012^^^這些僅僅是示例名稱 – king 2011-06-16 23:25:01

0

應該

update tablename set column1 = 'test' where column2 = 'xy' and column3 = 'xx' 

這單表更新語法:

UPDATE [LOW_PRIORITY] [IGNORE] table_reference 
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ... 
[WHERE where_condition] 
[ORDER BY ...] 
[LIMIT row_count]