求解释一段sql语句
CREATE OR REPLACE VIEW vw_news
AS
SELECT a.*, ROUND(SYSDATE - TO_DATE(upddate, 'YYYY-MM-DD HH24:MI:SS')) datesexp, b.uname, NVL(项目名, '-') projectname FROM
(t_news a
INNER JOIN t_user b ON a.userid = b.id)
LEFT OUTER JOIN t_project c ON a.projectid = c.项目编号
WHERE a.id <> 0
-- ORDER BY a.isbig ASC, a.isrcmd ASC, a.ord ASC, a.id DESC
;
求解释这几句代码是什么意思啊?
还有,如果我想把T_PRJNODETASKS中给的 计划完成时间 实际完成时间 任务描述 这三个字段加到这个视图中,应该怎么改代码呢?
------解决方案--------------------相当于
SELECT a.*, ROUND(SYSDATE - TO_DATE(upddate, 'YYYY-MM-DD HH24:MI:SS')) datesexp, b.uname, NVL(项目名, '-') projectname FROM
t_news a ,t_user b ,t_project c
WHERE a.id <> 0
and a.userid = b.id
and a.projectid = c.项目编号(+);
加上d表
SELECT a.*, ROUND(SYSDATE - TO_DATE(upddate, 'YYYY-MM-DD HH24:MI:SS')) datesexp, b.uname, NVL(项目名, '-') projectname FROM
t_news a ,t_user b ,t_project c, T_PRJNODETASKS d
WHERE a.id <> 0
and a.userid = b.id
and a.projectid = c.项目编号(+)
--你没给d表的字段啊
and a.projectid = d.项目编号(+);
------解决方案--------------------SELECT a.*,
ROUND(SYSDATE - TO_DATE(upddate, 'YYYY-MM-DD HH24:MI:SS')) datesexp,
b.uname, NVL(项目名, '-') projectname FROM
t_news a
INNER JOIN t_user b ON a.userid = b.id)
LEFT OUTER JOIN t_project c ON a.projectid = c.项目编号
WHERE a.id <> 0
系统日期减去upddate日期 四舍五入,nvl如果项目名为空,显示'-' 等值连接一下t_user 表 关联条件a.userid = b.id 在左连接 连接条件 a.projectid = c.项目编号
------解决方案--------------------SELECT a.*,
ROUND(SYSDATE - TO_DATE(upddate, 'YYYY-MM-DD HH24:MI:SS')) datesexp,
b.uname,
NVL(项目名, '-') projectname,
d.计划完成时间,
d.实际完成时间,
d.任务描述
FROM (t_news a INNER JOIN t_user b ON a.userid = b.id)
LEFT OUTER JOIN t_project c ON a.projectid = c.项目编号
LEFT OUTER JOIN T_P