2013-10-30 77 views
-2

下面是該查詢:錯誤後1列的MySQL UPDATE語法

UPDATE clubs WHERE clubId = $clubId SET (name='$name', category = '$category', 'description' = '$description', president = '$president', email = '$email', phone = $phone', treasurer = $treasurer', treasurerEmail = $treasurerEmail',treasurerPhone = $treasurerPhone', advisor = '$advisor', advisorEmail = '$advisorEmail', projectCode = '$projectCode', rollover = $rollover)" 

,當我嘗試我得到這個錯誤並運行它:在更新俱樂部 發生錯誤「}您的SQL錯誤語法;檢查對應於您的MySQL服務器版本的手冊,以便在第1行WHERE clubId = 1 SET(name ='Radio',category ='Media','descri')附近使用正確的語法

任何想法?

+2

WHERE子句來___after___ SET值的列表(你不需要在你的SET列名/值括號) –

+0

SQL沒有,但它應該有WHERE之前設置。意外拋出WHERE子句是破壞性的,但如果它只是返回一個語法錯誤,則不會。 – Popnoodles

回答

2

使用這一個:

UPDATE clubs SET name = '$name', category = '$category', description = '$description', president = '$president', email = '$email', phone = '$phone', treasurer = '$treasurer', treasurerEmail = '$treasurerEmail', treasurerPhone = '$treasurerPhone', advisor = '$advisor', advisorEmail = '$advisorEmail', projectCode = '$projectCode', rollover = '$rollover' WHERE clubId = '$clubId' 

也有一堆的'出來的地方。

編輯sql只爲popnoodles。

UPDATE clubs SET 
name = '$name', 
category = '$category', 
description = '$description', 
president = '$president', 
email = '$email', 
phone = '$phone', 
treasurer = '$treasurer', 
treasurerEmail = '$treasurerEmail', 
treasurerPhone = '$treasurerPhone', 
advisor = '$advisor', 
advisorEmail = '$advisorEmail', 
projectCode = '$projectCode', 
rollover = '$rollover' 
WHERE clubId = '$clubId' 
+0

爲什麼你沒有換行可讀性? – Popnoodles

1

您需要將WHERE放在語句末尾

UPDATE clubs SET name='$name', category = '$category', 'description' = '$description', president = '$president', email = '$email', phone = $phone', treasurer = $treasurer', treasurerEmail = $treasurerEmail',treasurerPhone = $treasurerPhone', advisor = '$advisor', advisorEmail = '$advisorEmail', projectCode = '$projectCode', rollover = $rollover WHERE clubId = $clubId