首页 > 其他 > 详细

mybatis 避免 where 1=1

时间:2020-04-28 15:32:45      阅读:251      评论:0      收藏:0      [点我收藏+]

mybatis 避免 where 1=1

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>

 

mybatis 避免 where 1=1

原文:https://www.cnblogs.com/muzhongjiang/p/12793964.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!