mybatis左連線需要輸出左表的指定內容與篩選

weixin_33896726發表於2017-09-26
  SELECT
      rpl.ID, rpl.DID, rpl.TRADE_TYPE, rpl.TRADE_TIME, rpl.CALL_TIME, rpl.TRADE_ADDR, rpl.RECEIVE_PHONE, rpl.CALL_TYPE, rpl.CREATE_DATE, rpl.CREATE_BY,
      rpl.STATE, rpl.REMARK, umci.contact_name
    FROM
           R360_Phonedetaillist rpl
           Left join User_Mobile_Contact_Info umci ON rpl.receive_phone = umci.contact_mobile_no
          <if test="userId != '' and userId != null">
            and umci.user_id = #{userId}
          </if>
    WHERE
           rpl.did = #{did}
    <if test="orderField != '' and orderField != null and orderDirection != '' and orderDirection != null">
      ORDER by ${orderField} ${orderDirection}
    </if>

 

相關文章