<!-- 多选
<choose>
<when test="title != null">
AND title like #{title}
</when>
<when test="author != null and author.name != null">
AND author_name like #{author.name}
</when>
<otherwise>
AND featured = 1
</otherwise>
</choose>
-->
<!-- 循环
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
-->
<!-- trim 在这的作用是去掉所包含的前缀AND 或者OR 其他属性(suffixOverrides去掉后缀,加上前缀prefix,加上后缀suffix)
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="state != null">
state = #{state}
</if>
<if test="title != null">
AND title like #{title}
</if>
<if test="author != null and author.name != null">
AND author_name like #{author.name}
</if>
</trim>
-->
Mybatis 简单的判断语法
最新推荐文章于 2024-07-04 18:54:02 发布