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

来源:5-4 交易模型管理--交易下单03

萧阳_0

2019-03-25 10:56

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.

写回答 关注

3回答

  • 一念清风
    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]



SpringBoot构建电商基础秒杀项目

应用SpringBoot快速搭建拥有用户、商品、交易及秒杀活动的电商秒杀应用。

49064 学习 · 954 问题

查看课程

相似问题