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
  • 相关阅读:
    商业即生活,一些思考和感悟
    Unity中使用摇杆控制
    在家乡做什么生意比较好?且看雷家第一智囊的分析
    Android5.0之Toobar的使用
    Android5.0常用颜色属性说明
    hiho week 38 P1 : 二分·二分答案
    CCF模拟题 字符串匹配
    CCF模拟题 最优配餐
    CCF模拟题 相反数
    CCF模拟题 最优灌溉
  • 原文地址:https://www.cnblogs.com/ccEmma/p/8980665.html
Copyright © 2011-2022 走看看