mybatis的if

<select id="findList" resultType="BndExport">
        SELECT 
            <include refid="bndExportColumns"/>
        FROM bnd_export a
        <include refid="bndExportJoins"/>
        <where>
            a.del_flag = #{DEL_FLAG_NORMAL}
            <if test="createDate != null and createDate != ''">
                AND a.create_date = #{createDate}
            </if>
            <if test="createDateStart!=null and createDateStart!='' and createDateEnd!=null and createDateEnd!=''">
                AND a.create_date between to_date('${createDateStart}','yyyy-mm-dd hh24:mi:ss') and to_date('${createDateEnd}','yyyy-mm-dd hh24:mi:ss')
            </if>
            <if test="company != null and company != ''">
                AND a.company = #{company}
            </if>
            <if test="bndExportFreight != null and bndExportFreight != '' and bndExportFreight.vessel != null and bndExportFreight.vessel != ''">
                AND b.vessel= #{bndExportFreight.vessel}
            </if>
            <if test="bndExportFreight != null and bndExportFreight != '' and bndExportFreight.voyage != null and bndExportFreight.voyage != ''">
                AND b.vessel= #{bndExportFreight.voyage}
            </if>
        </where>

  

猜你喜欢

转载自www.cnblogs.com/lijiasnong/p/9843797.html