首页  >  问答  >  正文

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 天前928

全部回复(2)我来回复

  • PHPz

    PHPz2017-04-18 10:34:02

    select order_id, uid, amount, pay_type, pay_time time,'2016' as y,'支付' 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 y,'提现' as order_type from fl_withdraw_order where uid=1001639998 and status=3

    回复
    0
  • 迷茫

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

    雷雷

    回复
    0
  • 取消回复