--- In [email protected], Svein Erling Tysvær 
<svein.erling.tysvaer@...> wrote:
>
> >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 */
> 
> From your description, I would guess you want something like
> 
> select f1, f2, f3 from t1 
>       where f1 = 'xxx'
> union
> select 0, 0, 0 from rdb$database
> where not exists(
>   select f1, f2, f3 from t1 
>       where f1 = 'xxx')
> union
> select f3, f4, f5 from t2
> 
> HTH,
> Set
>


Thanks, this is just my expected result.

but my query , like this, 

    select f1, f2, f3 from t1 where f1 = 'xxx'

is a very long long sql,would you have a more simple way to write?


My English is very terrible, hope you can understand me. 

thanks.





Reply via email to