今天开发接了一个很BT的需求。
找一个人的所有好友,查询所有好友的所有作品,然后按照时间倒序排列,取若干记录,
然后关联作品评论表。
作品包括原唱表,翻唱表,伴奏表,视频表,博客表和照片表,
不同的作品类型还要关联不同的专辑表,最后还要关联用户表..
--------------------------------------------------------------------------------
Linux-6-64下安装Oracle 12C笔记
在CentOS 6.4下安装Oracle 11gR2(x64)
Oracle 11gR2 在VMWare虚拟机中安装步骤
Debian 下 安装 Oracle 11g XE R2
--------------------------------------------------------------------------------
结果就是这个SQL很长...
with
t1 as (select to_userid from friend_list f where f.userid=411602438),
t2 as (
select 'mc' as t,rid,createtime
from
(
select mc.rowid rid,mc.createtime from music_cover mc,t1 where mc.userid=t1.to_userid and mc.opus_stat >0 order by mc.createtime desc
) where rownum< 100
union all
select 'mo',rid,createtime
from
(
select mo.rowid rid,mo.createtime from music_original mo,t1 where mo.userid=t1.to_userid and mo.opus_stat >0 order by mo.createtime desc
) where rownum< 100
union all
select 'mv',rid,createtime
from
(
select mv.rowid rid,mv.createtime from music_video mv,t1 where mv.userid=t1.to_userid and mv.opus_stat >0 order by mv.createtime desc
) where rownum< 100
union all
select 'ma',rid,createtime
from
(
select ma.rowid rid,ma.createtime from music_accompany ma,t1 where ma.userid=t1.to_userid and ma.opus_stat >0 order by ma.createtime desc
) where rownum< 100
union all
select 'bl',rid,createtime
from
(
select bl.rowid rid,bl.createtime from blog_list bl,t1 where bl.userid=t1.to_userid and bl.opus_stat >0 order by bl.createtime desc
) where rownum< 100
union all
select 'pl',rid,createtime
from
(
select pl.rowid rid,pl.createtime from photo_list pl,t1 where pl.userid=t1.to_userid and pl.opus_stat >0 order by pl.createtime desc
) where rownum< 100
),
t3 as
(
select * from
(
select * from t2 order by createtime desc
)
where rownum