in

<select>
select * from table where id in
<foreach open="(" close=")" separater="," collection="list" item="item" index="index">
#{item}
</foreach>
</select>

说明

open:以什么来开始。

close:用什么来关闭。

separater:分隔符

collection:集合,可以是array或list。

item:代表每次循环的值。

index:代表每次索引位。

QueryWrapper

使用 Mybatus-plus 的 QueryWrapper 之 in 查询,in(“字段名称”,集合),里边不要使用数组,不然不生效,要使用集合才可以。

like

⽅法1:concat
<where>
<trim  suffixOverrides="," >
<if test="id != null and id != ''" >
and id =  #{id}
</if>
<if test="name != null and name != ''" >
and name like concat('%',#{name},'%')
</if>
</trim>
</where>
⽅法2:${}
<if test="examTypeName!=null and examTypeName!=''">
and exam_type_name like '%${examTypeName}%'
</if>
⽅法3:#{}
<if test="examTypeName!=null and examTypeName!=''">
and exam_type_name like "%"#{examTypeName}"%"
</if>

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐