mybatis xml 映射文件 sql-include 的用法


    <sql id = "Condition_List">

        
        <if test="query.partnerType != null" >
            and a.type = #{query.partnerType}
        if>
        
        <if test="query.areaCode != null" >
            and a.area_code = #{query.areaCode}
        if>
        
        <if test="query.brandIds != null" >
            and LOCATE(#{query.brandIds},a.car_brand_id)>0
        if>
        
        <if test="query.key != null" >
            and a.name like concat('%',#{query.key},'%')
        if>
        
        <if test="query.createTime != null" >
            and a.create_time between #{query.createTime[0]} and #{query.createTime[1]}
        if>

    sql>
 <include refid="Condition_List" />