查询多表集合(union)、查询时建临时字段、查询时给字段设置默认值

 1 (select recharge_arrive_time as time,recharge_amount as amount,state,'充值' AS type from onlinerecharge where user_id=1)
 2 UNION 
 3 (select confirm_time as time,withdraw_cash_amount as amount,state,'提现' AS type from withdrawcash where user_id=1)
 4 UNION 
 5 (select i.create_time as time,i.investment_amount as amount,i.invest_state as state, b.bid_name as type from invest i
 6 INNER JOIN bid b
 7 on i.bid_id=b.bid_id
 8 where i.user_id=1)
 9 UNION 
10 (select r.exact_repayment_time as time,r.should_repayment_amount as amount,r.state as state, b.bid_name as type from repayment r 
11 INNER JOIN bid b
12 on r.bid_id=b.bid_id
13 where r.user_id=1)
14 UNION 
15 (select created_date_long as time,reward_amount as amount,reward_source as state,reward_name AS type  from investreward where user_id=1)
16 UNION 
17 (select a.created_date_long as time,a.actual_amount as amount,ac.amount as state,'多利宝存入' as type from dollyadd a
18 INNER JOIN dollyflow f
19 on a.dolly_flow_id= f.dolly_flow_id
20 INNER JOIN dollyaccount ac
21 ON a.user_id = ac.user_id
22 where a.user_Id = 1)
23 UNION
24 (select r.redeeml_arrive_time as time,r.amount as amount,'' as state,'多利宝赎回' as type from dollyredeem r
25 INNER JOIN dollyflow f
26 ON r.dolly_flow_id=f.dolly_flow_id
27 where r.user_id=1)
28 UNION
29 (select u.hb_get_time as time,h.hongbao_amount as amount,h.hongbao_name as state,'红包奖励' as type from userhongbao u 
30 INNER JOIN hongbao h
31 ON u.hongbao_id= h.hongbao_id
32 where user_id=1)
33 ORDER BY time DESC

 

转载于:https://www.cnblogs.com/ccEmma/p/8980665.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值