>  Q&A  >  본문

java - mybatis中如何写mysql的union all 查询?

mybatis如何写下边的sql?

select order_union.* from 
(select order_id, uid, amount, pay_type, pay_time time,'2016' ,'支付' as order_type from fl_pay_order where uid=1001639998 and status=1
UNION ALL 
select order_id, uid ,amount , null as pay_type, pay_time time ,'2017','提现' as order_type from fl_withdraw_order where uid=1001639998 and status=3)
as order_union
order by order_union.time desc limit 0,10
PHP中文网PHP中文网2741일 전923

모든 응답(2)나는 대답할 것이다

  • PHPz

    PHPz2017-04-18 10:34:02

    fl_pay_order에서 order_id, uid, amount, pay_type, pay_time time, '2016'을 y로, '支付'을 order_type으로 선택합니다. 여기서 uid=1001639998 및 status=1
    UNION ALL
    order_id, uid,amount를 선택합니다. , null은 pay_type, pay_time 시간, '2017'은 y, '提现'는 fl_withdraw_order의 order_type, 여기서 uid=1001639998 및 status=3

    회신하다
    0
  • 迷茫

    迷茫2017-04-18 10:34:02

    으아악

    회신하다
    0
  • 취소회신하다