CAST()函数

  1. <select id="exportExtAll" resultType="com.hq.domain.entity.order.vo.StatementExtExportVO">
  2. select o.order_id,o.order_no,o.money_used as orderUsed,o.create_time as moneyeceivedTime,
  3. s.money_received,s.money_available,s.money_used,s.ext_order_no,s.ext_pay_time,s.ext_pay_type,s.ext_status,s.exception_status,s.use_status,
  4. m.name as settlementName,
  5. bos.deal_school_name as schoolName, bos.teacher_recruit_name as teacherName
  6. from t_statement_order o
  7. left join t_statement s on o.statement_id = s.id
  8. left join t_settlement_method m on s.settlement_id = m.id
  9. left join biz_order_saleman bos on cast(o.order_id as char) = bos.order_id
  10. <where>
  11. <if test="settlementId != null">
  12. s.settlement_id = #{settlementId}
  13. </if>
  14. <if test="extOrderNo != null and extOrderNo !=''">
  15. and s.ext_order_no like concat('%',#{extOrderNo},'%')
  16. </if>
  17. <if test="startTime != null and startTime !=''">
  18. and s.ext_pay_time &gt;= #{startTime}
  19. </if>
  20. <if test="endTime != null and endTime !=''">
  21. and s.ext_pay_time &lt;= #{endTime}
  22. </if>
  23. <if test="exceptionStatus != null">
  24. and s.exception_status = #{exceptionStatus}
  25. </if>
  26. <if test="useStatus != null">
  27. and s.use_status = #{useStatus}
  28. </if>
  29. and s.ext_order_no is not null
  30. </where>
  31. order by s.ext_pay_time desc
  32. </select>
  1. select a.*,b.* from a left join b on a.aid = b.aid and b.dr = 0
  2. where a.status = 1;
  3. -- left join on 后面带and条件时,and条件只对left join右面的表起作用,对left join左面的表不起作用