类似这样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;