Mybatis一次执行多条sql,一个标签多个Insert、update、delete *** 作

Mybatis一次执行多条sql,一个标签多个Insert、update、delete *** 作,第1张

再平时的工作、学习中,我们会遇见插入,修改,删除多个表的 *** 作,我们不可能写多条insert标签等,这就需要在一个标签中写多个SQL语句

  
        insert into enters_sells_saves.purchase ( amount, price, purchase_time)
        values (#{amount},#{price},#{purchaseTime});
        insert into enters_sells_saves.goods (goods_name)
        values (#{goodsName});
        insert into enters_sells_saves.supplier (supplier_name)
        values (#{supplierName});
    

需要我们在数据库连接配置中加入:

allowMultiQueries=true

如:

jdbc:mysql://localhost:3306/enters_sells_saves?useSSL=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT&allowMultiQueries=true

这样就可以在一个标签中使用多个sql语句了

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/723994.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-26
下一篇 2022-04-26

发表评论

登录后才能评论

评论列表(0条)

保存