mybatis动态SQL之where标签

时间:2020-10-18 17:10:41   收藏:0   阅读:48

mybatis动态SQL之where标签

为了简化 where 1=1 的条件拼装,我们可以采用where标签来简化开发

<!-- 根据用户信息查询 -->
<select id="findByUser" resultType="user" parameterType="user"> 
   select * from user
    <where> 
    	<if test="username!=null and username != ‘‘ ">
   			 and username like #{username}
    	</if> 
         <if test="address != null">
   			 and address like #{address}
    	</if>
    </where>
</select>
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!