Subject | Re: how to union a dubious query to another query |
---|---|
Author | ibmcom2011 |
Post date | 2011-10-27T13:58:41Z |
--- In firebird-support@yahoogroups.com, Svein Erling Tysvær <svein.erling.tysvaer@...> wrote:
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.
>Thanks, this is just my expected result.
> >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
>
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.