日期:2014-05-17  浏览次数:21463 次

查询时怎么把oracle表中为空的字段也显示出来?
    name   no   degree
1   张三    0001     80
2   李四    0002    
3   王五    0003     79
4   毛竹    0004     
比如这张表,如果用select * from 表名 ,不显示2,4这两行,如何把这两行把这两行也显示出来,同时degree那里填上null?用pl/sql 怎么写呢?谢谢各位高手指点!
Oracle PL/SQL select

------解决方案--------------------
改成左连接。
------解决方案--------------------
select student.no,name,degree from student,score where student.no=score.no(+)

或者

select student.no,name,degree from student left join score  on  student.no=score.no
------解决方案--------------------
左连接,上面已经有人说过了

------解决方案--------------------
SELECT st.no, st.name, nvl(sc.degree, 'null') AS degree
  FROM student st
  LEFT JOIN score sc
    ON st.no = sc.no;