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

解决方案 »

  1.   

    你这问的有问题吧?
    select * from 表名  是显示这2行的
      

  2.   

    select * from 表名  是显示2,4行的,如果要显示成null的话,转换一下了
    select name,no,nvl(degree,'null') from 表名
      

  3.   

    对不起刚才两位回答的朋友,我表述问题确实很有问题,我的意思是这样的:如果有一张student表,里面有一些学生,包括no,name等字段,另外有一张score表,包括no,degree表,我要多表查询,查询出student表里的学生的成绩,应该是select student.no,name,degree from student,score where student.no=score.no,可是有的学生没有选课,我也想把他们显示出来,成绩(degree)那一字段设成null,怎么用pl/sql语句写呢?
      

  4.   

    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
      

  5.   

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