select id,name from test where id=1 group by id,name
union all
select 0 id,'0' name from dual where (select count(*) from test where id=1) =0
--当一个查询没有返回任何行,又想返回一行,而且返回值为0,可以用如上语句。
缺点:同一个语句执行了两次,耗费资源
select id,name from test where id=1 group by id,name
union all
select 0 id,'0' name from dual where (select count(*) from test where id=1) =0
--当一个查询没有返回任何行,又想返回一行,而且返回值为0,可以用如上语句。
缺点:同一个语句执行了两次,耗费资源