With sql we can make unions and intersections.
But does sql manage exclusivity?
Imagine we have 2 tables:
- one containing "all the people"
- the second containing "a short list of people", which can be empty
Can we create a view containing: the "list", if not empty, otherwise the "all people table" ?
In other words I need a different join (inner or outer) depending on the existence of a not empty table.
Thanks for your help,
select * from t1 where not exists ( select * from t2)
you can also do
select * from t1 where c1 not in (
select c1 from t2)
So the answer is yes.
This is not exactly what I need.
if t2 is not empty, then t2
if t2 is empty, then t1
It might not be the most efficient query in the world, but will give you what you want:
SELECT * FROM t2
SELECT * FROM t1 WHERE NOT EXISTS
(SELECT NULL FROM t2 WHERE ROWNUM=1);
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
Click Here to Expand Forum to Full Width