zoukankan      html  css  js  c++  java
  • 查询多表集合(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
  • 相关阅读:
    组合数学+结论——cf1359E
    【模拟】分类讨论大模拟+数论——cf1358F
    【思维】前缀和——cf1358E
    Android基础—— 自定义RecyclerView内部控件的监听器
    【思维】模拟+暴力——icpc nwrrc 2019 K
    分治模板
    树上问题&图论模板整理
    数据结构模板整理
    一些计数题
    Codeforces Round #567 (Div. 2)
  • 原文地址:https://www.cnblogs.com/ccEmma/p/8980665.html
Copyright © 2011-2022 走看看