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
  • 相关阅读:
    Linux下关于信号block与unblock的小研究
    perl打印乘法表
    Linux下libaio的一个简单例子
    heritrix的简单使用以及在后台调用heritrix
    perl修改文件内容
    Linux下mmap函数的一个练习
    Linux real uid 和 effective uid相关总结
    阶段性小总结
    归并排序的一个练习
    利用openssl进行base64的编码与解码
  • 原文地址:https://www.cnblogs.com/ccEmma/p/8980665.html
Copyright © 2011-2022 走看看