重庆思庄Oracle、Redhat认证学习论坛

标题: 【课后习题】SQL第五章第3题 [打印本页]

作者: 5dm    时间: 2012-11-27 11:24
标题: 【课后习题】SQL第五章第3题

多张写法,列出两个:

方法一:多表关联

SQL> select e.last_name,d.department_id,d.department_name
  2  from departments d join employees e on d.department_id=e.department_id
  3  join locations l on d.location_id=l.location_id and  l.city='Toronto';

LAST_NAME                 DEPARTMENT_ID DEPARTMENT_NAME
------------------------- ------------- ------------------------------
Hartstein                            20 Marketing
Fay                                  20 Marketing

 

方法二:子查询
select e.last_name,department_id,d.department_name
from departments d  join employees e using(department_id)

where d.location_id=(select location_id from locations where city='Toronto');


 

[此贴子已经被作者于2012-11-27 11:45:01编辑过]

作者: 张清扬    时间: 2013-5-6 11:05

这种join..on的写法有什么特别的好处么?


作者: 郑全    时间: 2013-5-6 15:06
join的写法,就是sql-99标准而已,不存在有特别的好处,要说好处,就是习惯了sql server的人,不用转换,就看得懂.




欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/) Powered by Discuz! X3.2