mybatis动态拼接条件的两种方式:
  • where 1=1
  • where标签

where标签方式:

<select id="findActiveBlogLike"  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>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
  • 2021-08-21
  • 2021-11-03
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
相关资源
相似解决方案