mybatis动态SQL之where标签

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>
记得快乐
原文地址:https://www.cnblogs.com/Y-wee/p/13835156.html