mybatis左连接需要输出左表的指定内容与筛选

  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>

 

posted @ 2017-09-26 18:04  guodaxia  阅读(502)  评论(0编辑  收藏  举报