MyBatis(一)select语句拼接方式


<select id="selectByForm" parameterType="com.xxx.controller.request.DeliveryQueryForm" resultMap="FullResultMap">

    select
    <if test="distinct">
        distinct
    </if>
    'true' as QUERYID,
    ro.order_code as order_code, ro.code as code, ro.name as name, 
    ro.reception_date as reception_date,r.status as status, d.driver_name as driver_name
    from tbl_order_drivers_relation r
    left join tbl_reservation_order ro on ro.order_code = r.order_code
    left join mst_drivers d on d.driver_id = r.driver_id
    <if test="_parameter != null">
        <include refid="Example_Where_Clause_Form" />
    </if>
        order by r.create_time
</select>
<sql id="Example_Where_Clause_Form">
    <where>
        <if test="orderCode != null and orderCode != ''">
            AND r.order_code = #{orderCode}
        </if>

        <if test="name != null and name != ''">
            AND ro.name like CONCAT(CONCAT('%', #{name}), '%')
        </if>
    </where>
</sql>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM