我正在尝试运行UPDATE
而我收到语法错误。我正在使用php和PDO来创建UPDATE
命令。我的语法出了什么问题?
更新教育WHERE userId =:userId AND fieldId =:fieldId SET fieldId =:fieldId,educationTitle =:educationTitle,educationDegree =:educationDegree,startDate =:startDate,endDate =:endDate,educationDescription =:educationDescription;
错误:
您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 'WHERE userId ='35'AND fieldId ='4'SET fieldId ='4'附近, educationTitle ='ththt'在第1行
更新:
我尝试在WHERE
之后放置SET
,如下面的示例所示,但我仍然遇到语法错误。
更新教育SET fieldId =:fieldId,educationTitle = :educationTitle,educationDegree =:educationDegree,startDate = :startDate,endDate =:endDate,educationDescription = :educationDescription,WHERE userId =:userId AND fieldId =:fieldId;
答案 0 :(得分:3)
将WHERE
放在SET
之后。
UPDATE education
SET fieldId = :fieldId,
educationTitle = :educationTitle,
educationDegree = :educationDegree,
startDate = :startDate,
endDate = :endDate,
educationDescription = :educationDescription
WHERE userId = :userId AND
fieldId = :fieldId