The result set A, equals to the select id from X.
The result set B is equal to the select id from Y;
SQL statements are as follows:
Select * from Z where z.i d in (here if A not null is the select id from X; If A null is the select id from Y)
The result set of A and B can be multiple values, purpose is to achieve A data when the result set A all have no, the choice of the result set B,
Consult the situation how to write SQL statements can realize,
A, preferably Oracle standard
thank you
CodePudding user response:
Select * from Z where z.i d in (NVL (A, B))???????CodePudding user response:
Select * from test3 where id in (select id from test1 union select id from
Test2, (select count (1) the count from test1) where the count=0);
CodePudding user response:
Select * from Z where z.i d in (select id from X)
The UNION
Select * from Z where z.i d in (select id from where Y=0 (select COUNT (id) from X))