问答详情
源自:5-4 交易模型管理--交易下单03

mysql语法问题,我使用的mysql是8.0.11

check the manual that corresponds to your MySQL server version for the right syntax to use near 'where item_id = 5 and stock >= 1' at line 3.

提问者:萧阳_0 2019-03-25 10:56

个回答

  • 一念清风
    2020-03-19 03:47:50

    在销量增加中犯了同样的错误,一开始就认为是sql语句错了,结果就是这个逗号被直接忽略,在service层浪费了两个半钟。。。感谢啊,要是没你的提示还不知道要搞多久。

  • 萧阳_0
    2019-03-25 11:27:52

    解决了,原来是没有删除

    set stock = stock - #{amount},

    这的逗号

  • 萧阳_0
    2019-03-25 11:19:03

    ### Error updating database.  Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where item_id = 5 and stock >= 1' at line 3

    ### The error may involve defaultParameterMap

    ### The error occurred while setting parameters

    ### SQL: update item_stock     set stock = stock - 1,     where item_id = 5 and stock >= 1

    ### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where item_id = 5 and stock >= 1' at line 3

    ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where item_id = 5 and stock >= 1' at line 3]