首页新闻找找看学习计划

sql语句查询多个表

0
悬赏园豆:140 [已解决问题] 解决于 2015-04-02 17:37

我现在有四张表,表结构不同,都是时间列,需要根据时间排序四张表的信息然后展示出来,那位大神给个思路,demo什么的。

第二个问题。。

(select plId as ID,plUserId as UserId,plTime as Times,'publish' as 'Staus' from publish ) as t1,

(select id as ID,userId as UserId,logTime as Times,'log' as 'Staus' from [log]) as t2

 

可不可以让t1 与t2的 列合并起来 然后根据时间排序

求指点

问题补充:

能有个例子是最好的

蓝小天的主页 蓝小天 | 初学一级 | 园豆:33
提问于:2015-04-02 16:56
< >
分享
最佳答案
0

select plId as ID,plUserId as UserId,plTime as Times,'publish' as 'Staus' from publish ) as t1

UNION ALL

select id as ID,userId as UserId,logTime as Times,'log' as 'Staus' from [log]) as t2

这样就可以了啊。

收获园豆:140
爱编程的大叔 | 高人七级 |园豆:30089 | 2015-04-02 17:00
其他回答(3)
0

大叔正解。

晓菜鸟 | 园豆:2594 (老鸟四级) | 2015-04-02 17:07
0

需要每个表都展示所有列的数据吗?

对于t1与t2合并,大叔的回答就ok了~

幻天芒 | 园豆:36544 (高人七级) | 2015-04-02 17:11
0

使用视图。

Firen | 园豆:5483 (大侠五级) | 2015-04-02 17:10
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册