oracle查询

来源:互联网 发布:sql怎么清除数据 编辑:程序博客网 时间:2024/04/29 13:35

今天用oracle左连接做一个查询,结果条件总是不起作用。

原来是这样写的 SELECT A.*,RA.* FROM PUB_AUTHORITY A LEFT JOIN PUB_ROLEAUTHORITY RA ON  RA.AUTHNUMBER=A.AUTHNUMBER where RA.rolenumber='CS9901'

浪费好久时间才发现。只要把where 改变为and,才会起作用。有点小疑问

下面 收藏点东西

oracle 空字符串 null 和各种判断当前字段是否为空 
情况一:

select (case when trim('      ') is not null then 'not null' else 'is null' end) as age from dual;

输出结果:age: 'is null'


情况二:删除trim()

select (case when '      ' is not null then 'is null' else 'not null' end) as age from dual;

输出结果:age: 'not  null'

由以上测试可以得出今后的判断条件为:


if (trim(nvl(var_name_str,''))='')  then

         begin

           your operation;

         end;

 end if;

nvl用法:nvl(arg,value)代表如果前面的arg的值为null那么返回的值为后面的value

 

0 0