真的。没有找到Oracle附带的sample表,所以请大家帮个忙,看下我写的这段查询语句有没有错,谢谢!d) 找出每位员工及其上司的名字,没有上司请显示“没有上司”select  a.First_name , b.Manager
from  S_EMP  a , S_DEPT  b
on  a.Manager_id = b.ID
where  nvl(b.manager,’没有上司’)

解决方案 »

  1.   


    select a.First_name , nvl(b.manager,’没有上司’)
    from S_EMP a 
    full join S_DEPT b on a.Manager_id = b.ID
      

  2.   

    select a.First_name , nvl(b.manager,’没有上司’)
    from S_EMP a , S_DEPT b
    where a.Manager_id = b.ID
      

  3.   

    -- on 是不行的,用 join 的时候,才用 on-- 例如:
    scott@TBWORA> select a.ename, a.sal, b.deptno
      2  from emp a, dept b
      3  on a.deptno=b.deptno;
    on a.deptno=b.deptno
    *
    第 3 行出现错误:
    ORA-00933: SQL 命令未正确结束
    scott@TBWORA> l
      1  select a.ename, a.sal, b.deptno
      2  from emp a, dept b
      3* on a.deptno=b.deptno
    scott@TBWORA> 3
      3* on a.deptno=b.deptno
    scott@TBWORA> c/on/where
      3* where a.deptno=b.deptno
    scott@TBWORA> l
      1  select a.ename, a.sal, b.deptno
      2  from emp a, dept b
      3* where a.deptno=b.deptno
    scott@TBWORA> /ENAME                       SAL     DEPTNO
    -------------------- ---------- ----------
    CLARK                      2450         10
    KING                       5000         10
    MILLER                     1300         10
    SMITH                       800         20
    JONES                      2975         20
    SCOTT                      3000         20
    ADAMS                      1100         20
    FORD                       3000         20
    ALLEN                      1600         30
    WARD                       1250         30
    MARTIN                     1250         30
    BLAKE                      2850         30
    TURNER                     1500         30
    JAMES                       950         30已选择14行。scott@TBWORA> select a.ename, a.sal, b.deptno
      2  from emp a join dept b
      3  on a.deptno=b.deptno;ENAME                       SAL     DEPTNO
    -------------------- ---------- ----------
    CLARK                      2450         10
    KING                       5000         10
    MILLER                     1300         10
    SMITH                       800         20
    JONES                      2975         20
    SCOTT                      3000         20
    ADAMS                      1100         20
    FORD                       3000         20
    ALLEN                      1600         30
    WARD                       1250         30
    MARTIN                     1250         30
    BLAKE                      2850         30
    TURNER                     1500         30
    JAMES                       950         30已选择14行。