Mybatis学习第一天

<select id="selectUser" parameterType="User" resultType="User">
        select * from user 
        <where> 
            <if test="id!=0">  
                 id = #{id}  
            </if>
            <if test="name!=null">
              and  name like '%'||#{name}||'%' 
            </if>  
        </where>
 </select>

 其中,and是必须写的,如果id为0的时候,mybatis会自动将“and”过滤。

猜你喜欢

转载自soco0605.iteye.com/blog/1631448