mapper operation

table of Contents

like

<select id="getCountDetailList" resultType="EnterpriseBidStaffDto">
        SELECT s.*,u.name as HandHRName from s_enterprise_bid_staff s
        left join s_enterprise_user  u on s.create_user= u.id
        <where>
            
            <if test="p.name != null and p.name != ''">
                and s.name  like CONCAT('%', #{p.name}, '%')
            </if>
            <!-- 第二种写法 -->
            <if test="p.name != null and p.name != ''">
                <bind name="name" value="'%'+p.name+'%'"/>
                and s.name  like #{name}
            </if>
        </where>
    </select>

Time comparison

<select id="getCountDetailList" resultType="EnterpriseBidStaffDto">
        SELECT s.*,u.name as HandHRName from s_enterprise_bid_staff s
        left join s_enterprise_user  u on s.create_user= u.id
        <where>
           
            <if test="p.startTime != null and p.startTime != ''">
                and
                <![CDATA[DATE_FORMAT(s.create_time , '%Y-%m-%d')>=  DATE_FORMAT(#{p.startTime}, '%Y-%m-%d')   ]]>
            </if>
            <if test="p.endTime != null and p.endTime != ''">
                and
                <![CDATA[DATE_FORMAT(s.create_time , '%Y-%m-%d')<=  DATE_FORMAT(#{p.endTime}, '%Y-%m-%d')   ]]>
            </if>

        </where>
    </select>

Guess you like

Origin www.cnblogs.com/ityangshuai/p/12692485.html