错误更新记录您的SQL语法有错误

时间:2019-02-04 13:55:57

标签: php json

我尝试更新表格,但出现此错误,请帮助我

INSERT INTO TBL_Attendance (columnName) VALUES (v1, v2...etc)
    SELECT columnName 
    FROM TBL_Students 
    WHERE column = 'value'

2 个答案:

答案 0 :(得分:0)

您需要将SQL查询视为字符串,并相应地连接变量:

"UPDATE posts SET title = '".$title."', content = '".$content."', date = '".$date."' , likes = '".$likes."', groups = '".$groups."' WHERE id = '".$id."'";

答案 1 :(得分:0)

您的where子句有2个等号。将其更改为单个等号...而且,date是保留字,因此您需要将其包装在反引号中。

$sqlCommand = "UPDATE posts
    SET title = '$title'     , 
         content = '$content',
        `date`   = '$date'   , 
         groups  = '$groups' 
    WHERE id = 1";