FIND_IN_SET 在mybatis的<foreach>中 使用

公司项目开发一个功能,制定标签,然后根据多标签查询;

最简单的还是标签做字典,这样,列表只要存一个  “,”    分割的字符串就行;

查询时候使用FIND_IN_SET   循环遍历出来就可以。

parameterType  是一个实体,
interfaceType 字段存的是   aa,bb,cc,dd,

foreach 要循环的是字符串,区别于循环list,所以要使用这个方法:(注意:sql语句 and中间没有  ,  所以要改一下 open="" close="" separator=" ")
复制代码
where ………

<if test=" interfaceType != null and interfaceType != ''"> <foreach collection="interfaceType.split(',')" item="item" index="index" open="" close="" separator=" "> and FIND_IN_SET(#{item},m.interface_type) </foreach> </if>
复制代码

 

posted @   百事没事  阅读(2038)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
点击右上角即可分享
微信分享提示