我是靠谱客的博主 强健高跟鞋,这篇文章主要介绍myabtis中使用not in与 in的写法,现在分享给大家,希望可以做个参考。

首先声明我不是很喜欢用foreach,所以我的代码中很少出现foreach。不废话了,上代码:

in的用法:

我的id是Long类型的

service方法,有一个Long的集合:

public List<RbacMenu> listByPackageId(List<Long> ids, String systemCode) {
String idsStr = String.join(",",ids);

实体类.xml

select * from xxx where

<if test="ids != null"> FIND_IN_SET(id,#{idsStr})
</if>

not in的用法

service方法,有一个Long的集合:

public List<RbacMenu> listByPackageId(List<Long> ids, String systemCode) {
String notids = String.join(",",ids);

实体类.xml

select * from xxx where

<if test="notids != null"> NOT FIND_IN_SET(id,#{notids})
</if>

最后

以上就是强健高跟鞋最近收集整理的关于myabtis中使用not in与 in的写法的全部内容,更多相关myabtis中使用not内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(68)

评论列表共有 0 条评论

立即
投稿
返回
顶部