Oracle to how to write?
Table 1 and table 2 structure, just is not the same as the content
CodePudding user response:
- can be written as such, but I suggest you write better in two steps,Select * from t1 where id=1
Union all
Select * from t2 where not the exists (select * from t1 where id=1)
CodePudding user response:
DeclareV_cnt int.
The begin
Select count (1) into v_cnt from table 1 where id=1 and rownum<2;
If v_cnt & gt; 0 then
Select * from table 1
The else
Select * from table 2
end if;
The end;
So, probably with hand written, no specific grammar, proofreading
CodePudding user response:
SELECTCASE
WHEN the rowcount & gt; 0 THEN
Select *
From table 1
The ELSE
SELECT *
FROM table 2
END
The FROM (
SELECT count (*) the rowcount
FROM table 1
WHERE id=1) a
CodePudding user response:
3 f, is realized by using the stored procedure supportCodePudding user response:
Select * from tab1 where the exists (select * from tab1 t1 where t1. Id=1)Union all
Select * from tab2 where not the exists (select * from tab1 t2 where t2. Id=1)
CodePudding user response:
Select * from a1 where the exists (select null from dual where a1. Id=1)Union all
Select * from a2 where not the exists (select null from a1 where a1. Id=1)