0

我正在尝试运行UPDATE,但出现语法错误。我正在使用 php 和 PDO 来创建UPDATE命令。我的语法有什么问题?

更新教育,其中 userId = :userId AND fieldId = :fieldId SET fieldId = :fieldId, educationTitle = :educationTitle,educationDegree = :educationDegree, startDate = :startDate, endDate = :endDate,educationDescription = :educationDescription;

错误:

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 'WHERE userId = '35' AND fieldId = '4' SET fieldId = '4', educationTitle = 'ththt' 附近使用正确的语法

更新:

我试过像下面的示例一样放置WHERESET但我仍然遇到语法错误。

更新教育集 fieldId =:fieldId,educationTitle =:educationTitle,educationDegree =:educationDegree,startDate =:startDate,endDate =:endDate,educationDescription =:educationDescription,其中 userId =:userId AND fieldId =:fieldId;

4

1 回答 1

3

放在WHERE后面SET

UPDATE  education  
SET     fieldId = :fieldId, 
        educationTitle = :educationTitle, 
        educationDegree = :educationDegree, 
        startDate = :startDate, 
        endDate = :endDate, 
        educationDescription = :educationDescription
WHERE   userId = :userId AND 
        fieldId = :fieldId
于 2013-04-02T08:19:02.247 回答