sql片段

 

   <!-- 3.if和where的使用-->
    <sql id="select_user_where">
        <if test="user != null">
            <if test="user.sex != null and user.sex != ''">
                sex = #{user.sex}
            </if>
            <if test="user.username != null and user.username != ''">
                and username LIKE '%${user.username}%'
            </if>
            <if test="user.address != null and user.address != ''">
                and address LIKE '%${user.address}%'
            </if>
        </if>
    </sql>
    <select id="findUserList" parameterType="userQueryVO" resultType="user">
        /*性别和名字*/
        SELECT * FROM user

        <where>
            <include refid="select_user_where"/>
        </where>
    </select>

 

 

 

 

 

posted @ 2019-08-13 22:33  expworld  阅读(78)  评论(0)    收藏  举报