Subject | RE: [IBO] IB_Query phenomenom |
---|---|
Author | Claudio Valderrama C. |
Post date | 2001-01-03T05:51:23Z |
> -----Original Message-----Guido, excuse me, but your SQL generator seems to have a bug. What the ****
> From: guido.klapperich@... [mailto:guido.klapperich@...]
>
> I have a IB_Query with the following SQL-Statement:
> select
> FD.FDID,FD.FDDCID,FD.FDDFID,FD.FDBONUS,
> A.FMID,A.FMFDID,A.FMMPID,(select MPNAME from MAINPRODUCTGROUPS where
> MPID=A.FMMPID) as MPNAME,A.FMDISCOUNT,A.FMDISCOUNTNEW
> ,
> B.FMID,B.FMFDID,B.FMMPID,(select MPNAME from MAINPRODUCTGROUPS where
> MPID=B.FMMPID) as MPNAME,B.FMDISCOUNT,B.FMDISCOUNTNEW
> ,
> C.FMID,C.FMFDID,C.FMMPID,(select MPNAME from MAINPRODUCTGROUPS where
> MPID=C.FMMPID) as MPNAME,C.FMDISCOUNT,C.FMDISCOUNTNEW
> from
> FOLLOWUPDISCOUNTS FD,
> FOLLOWUPDISCOUNTS_MP A
> ,
> FOLLOWUPDISCOUNTS_MP B
> ,
> FOLLOWUPDISCOUNTS_MP C
> where
> A.FMFDID=FD.FDID
> and A.FMMPID=11
> and
> B.FMFDID=FD.FDID
> and B.FMMPID=12
> and
> C.FMFDID=FD.FDID
> and C.FMMPID=13
do you want to achieve? You are doing, to narrow the issue:
select field,
(select f from tbl1 where...) as FNAME,
(select f from tbl2 where...) as FNAME,
(select f from tbl3 where...) as FNAME,
field2
from t1
Several fields with the same alias? Man, you are looking for problems at
all levels! For explicit joins, you should convert
select a.f, b.f from a, b where a.l=b.l
into the ANSI SQL form
select a.f, b.f from a JOIN b ON a.l=b.l
and I will leave for you to decide if you need a left join, for example,
because the explicit JOIN syntax is the only way to specify such
construction. IB has no proprietary =* operator as MsSql.
Do you want several rows or several fields? For several fields, give each
subquery a different column name. For several rows, build a statement with
two or more SELECT commands glued by UNION ALL statements. In any case,
inside each SELECT, prefer the explicit JOIN/ON syntax.
C.