1列后的MySQL UPDATE语法错误

时间:2013-10-30 20:48:20

标签: php mysql sql

以下是查询:

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服务器版本对应的手册,以便在'WHERE clubId = 1 SET(name ='Radio',category ='附近使用正确的语法媒体','描述'在第1行

有什么想法吗?

2 个答案:

答案 0 :(得分: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'

你也有一堆'不合适。

仅为popnoodles编辑sql。

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'

答案 1 :(得分: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