oracle中想换表查询,判断条件怎么写

实现功能:如果表2为空就查表一,否则查询表1
if exists (select 0 from table2)
select * from table 1
else
select * from table 2
这样的语句实现不了,在oracle中该怎么写

你的问题应该是实现功能:如果表2为空就查表一,否则查询表2吧
select * from table2
union
select * from table1
where (select count(*) from table2 )=0

select * from table2
where (select count(*) from table1 )=0--需要加多一个条件
union
select * from table1
where (select count(*) from table2 )=0