mybatis的where标签

简介: mybatis的where标签
<select id="findBlog" resultType="Blog">
  SELECT * FROM BLOG 
  <where> 
    <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>
  </where>
</select>

where标签可以去除 额外 and / or

<trim prefix="WHERE" prefixOverrides="AND |OR "> ... </trim>


相关文章
|
SQL Java 数据库连接
28MyBatis - 动态SQL的 if标签
28MyBatis - 动态SQL的 if标签
75 0
|
SQL XML Java
mybatis之动态SQL常见标签的使用
mybatis之动态SQL常见标签的使用
148 0
|
4月前
|
SQL XML Java
Mybatis的<where>,<if>等标签用法
这篇文章详细解释了Mybatis中<where>和<if>等标签的用法,展示了如何在SQL动态构建中有效地过滤条件和处理逻辑分支。
379 1
|
Java 数据库连接 mybatis
mybatis的where标签
mybatis的where标签
|
SQL
29MyBatis - 动态SQL的 where标签
29MyBatis - 动态SQL的 where标签
56 0
|
SQL XML Oracle
常用的Mybatis标签介绍(六)
常用的Mybatis标签介绍(六)
76 2
|
SQL XML Java
常用的Mybatis标签介绍(三)
常用的Mybatis标签介绍(三)
105 3
|
SQL XML Java
常用的Mybatis标签介绍(一)
常用的Mybatis标签介绍(一)
226 2
|
SQL Java 数据库连接
常用的Mybatis标签介绍(二)
常用的Mybatis标签介绍(二)
82 2
|
Java 数据库连接 数据库
常用的Mybatis标签介绍(四)
常用的Mybatis标签介绍(四)
80 1

热门文章

最新文章