MyBatis(一)select语句拼接方式

2021/5/6 18:55:18

本文主要是介绍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>

 



这篇关于MyBatis(一)select语句拼接方式的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程