有次需要完成一个功能的时候sql语句用到id NOT IN
一开始这个参数我在impl 用字符串拼接好了,如 (123,456,789)
通过dao层的mapper传入xml,运行后,报错

拉到下面看详细信息,
Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 '' (13690,13693,13691,13692,13716,13714,13715,13718,13719,13720,13712,13713,13721' at line 3
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 xxxxxx
然后就不采用字符串先拼接好的方法,直接丢一个map进去循环遍历,在xml中完成拼接
接下来看看my
最后
以上就是大气冬日最近收集整理的关于mysql循环map_Java mybatis 循环遍历map的全部内容,更多相关mysql循环map_Java内容请搜索靠谱客的其他文章。
发表评论 取消回复