oracle怎么能给所有select字段赋默认值
类似这样sql:select 字段1,字段2,‘hello,world’ from table1 where 字段1=?,
如果没有数据,还希望输出hello,world,其他两个字段,随便填个值,比如0
必须有where,实际根据这个where条件表里有时会有数据,有时是没有匹配的数据的,但是没有匹配数据的时候还希望输出hello,world,其他两个字段,随便填个值,比如0。\
-- 用union all加以解决: -- 例如: select c1, c2 from (select c1, c2 from tb_name union all select 'hello' as c1, 'world' as c2 from dual) t where rownum=1; select c1, c2 from (select ename as c1, job as c2 from emp where empno=7900 union all select 'hello' as c1, 'world' as c2 from dual) t where rownum=1; select c1, c2 from (select ename as c1, job as c2 from emp where empno=7901 union all select 'hello' as c1, 'world' as c2 from dual) t where rownum=1;
select max(dummy) dmy,'hello world' hi from dual where 1=1; select max(dummy) dmy,'hello world' hi from dual where 1=2;