This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center
                            
                        
                    
                
                                6年前关闭。
            
                    
我正在尝试运行UPDATE,并且出现语法错误。我正在使用php和PDO创建UPDATE命令。我的语法有什么问题?


  UPDATE教育在哪里userId =:userId和fieldId =:fieldId SET
  fieldId =:fieldId,educationTitle =:educationTitle,educationDegree
  =:educationDegree,startDate =:startDate,endDate =:endDate,educationDescription =:educationDescription;


错误:


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


更新:

我曾尝试将WHERE放在SET之后,如下面的示例,但是我仍然遇到语法错误。


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

最佳答案

WHERE放在SET之后。

UPDATE  education
SET     fieldId = :fieldId,
        educationTitle = :educationTitle,
        educationDegree = :educationDegree,
        startDate = :startDate,
        endDate = :endDate,
        educationDescription = :educationDescription
WHERE   userId = :userId AND
        fieldId = :fieldId

10-06 07:07