Subject | how to union a dubious query to another query |
---|---|
Author | ibmcom2011 |
Post date | 2011-10-27T11:19:54Z |
i want to union a query A to an other query B, if no any record in a, then automatically switch the 3rd query C to union the B. otherwise, the A can union to B.
now i try to do it such as:
select 0, 0, 0 from t1 /* C */
where not exists(
select f1, f2, f3 from t1
where f1 = 'xxx' /* A */
)
union
select f3, f4, f5 from t2 /* B */
now i try to do it such as:
select 0, 0, 0 from t1 /* C */
where not exists(
select f1, f2, f3 from t1
where f1 = 'xxx' /* A */
)
union
select f3, f4, f5 from t2 /* B */