Sql语法错误号1064

时间:2016-03-11 14:38:42

标签: mysql

查询:

$Sql ="
    UPDATE 
        pick_up_address
    SET 
        user_id                 = '" . $movers_id . "',
        member_group_id         = '" . $member_group_id . "',
        nick_name               = '" . $_POST[' nick_name '][$i] . "',
        contact_person_name     = '" . $_POST[' contact_person_name '][$i] . "',
        contact_person_number   = '" . $_POST[' contact_person_number '][$i] . "',
        contact_address         = '" . $_POST[' contact_address '][$i] . "'
    WHERE
        pick_up_address_id      = '" . $pick_adddress_id[$i] . "',
        lat                     = '" . $lat1 . "',
        lng                     = '" . $lng1 . "'";

错误讯息:

  

您的SQL语法有错误;检查手册   对应于您的MySQL服务器版本,以便使用正确的语法   near lat =" value",lng =" value"

1 个答案:

答案 0 :(得分:0)

当您尝试在代码段中时,无法用逗号连接WHERE子句。相反,你必须使用AND或OR等运算符。

所以而不是

... WHERE pick_up_address_id='".$pick_adddress_id[$i]."', lat='".$lat1."' ...`

尝试类似

的内容
... WHERE pick_up_address_id='".$pick_adddress_id[$i]."' AND lat='".$lat1."' ...`

这些WHERE子句的语法在mysql文档中精确定义,但实际上这只是标准的SQL语法:

http://dev.mysql.com/doc/refman/5.7/en/select.html