sql多表联合查询

菜鸟跪求大神指导:怎样用sql语句实现将下面的10个表联合查询?我有10个表aut_user_recharge_record_1,aut_user_recharge_re... 菜鸟跪求大神指导:怎样用sql语句实现将下面的10个表联合查询?
我有10个表aut_user_recharge_record_1,aut_user_recharge_record_2 ........字段一样,如图

查寻出来如下效果
展开
 我来答
0808xyj
推荐于2018-04-15 · TA获得超过1891个赞
知道大有可为答主
回答量:1237
采纳率:100%
帮助的人:1055万
展开全部
十张表加起来的数据量 大概是多少? 若数据量 不是很大的话,可以按照 古舟蓑笠翁 的做法来
你SQL 中的from_unixtime 函数,这样 跑法,速率应该不是 很高吧!?

建议 分步骤去做,先把时间戳 换成 datetime 后,再一步一步汇总统计,统计规则,你是很清楚的
百度网友2dca20d
推荐于2016-03-07 · TA获得超过4034个赞
知道大有可为答主
回答量:2638
采纳率:77%
帮助的人:976万
展开全部
select datanum,pay_type,datatime
from (select * from aut_user_recharge_record_1
union all select * from aut_user_recharge_record_2
union all select * from aut_user_recharge_record_3
union all select * from aut_user_recharge_record_4
union all select * from aut_user_recharge_record_5
union all select * from aut_user_recharge_record_6
union all select * from aut_user_recharge_record_7
union all select * from aut_user_recharge_record_8
union all select * from aut_user_recharge_record_9
union all select * from aut_user_recharge_record_10)
更多追问追答
追问
create_time是时间戳  还报( # 1248 -每一个派生表必须有它自己的别名)错
追答
那你的日期值是从哪来的?
select datanum,pay_type,datatime
from (select * from aut_user_recharge_record_1
union all select * from aut_user_recharge_record_2
union all select * from aut_user_recharge_record_3
union all select * from aut_user_recharge_record_4
union all select * from aut_user_recharge_record_5
union all select * from aut_user_recharge_record_6
union all select * from aut_user_recharge_record_7
union all select * from aut_user_recharge_record_8
union all select * from aut_user_recharge_record_9
union all select * from aut_user_recharge_record_10) A
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式