Subject Re: [ib-support] Ambiguous query or bug ?
Author Lucas Franzen
Béru schrieb:
>
> JJM posted the following problem on the french IB newsgroup:
>
> > SELECT RQSEL.D_KEYID
> > FROM RQSEL
> > INNER JOIN RQSEL R1
> > ON (RQSEL."D_KEYID" = R1."D_KEYID")
> > WHERE
> > (RQSEL.WO_WORD = 'CIVILES' AND R1.WO_WORD = 'ADMIN')
> >
> > j'obtiend le message :
> > Undefined name.
> > Dynamic SQL Error.
> > SQL error code = -204.
> > Ambiguous field name between table/view RQSEL and table/view
> RQSEL.D_KEYID.
>
> I don't think there is an ambiguity in his query... Is this a known
> bug in the ambiguities-checking code ?

RQSEL is ambiguos since you have an inner join but only one alias.
You're using an alias R1 for the inner join but haven't got an alias for
the main-select portion. So RQSEL.D_KEYID is referred twice anyway.

I think if you change it to :

SELECT RQ.RQSEL.D_KEYID
FROM RQSEL RQ
INNER JOIN RQSEL R1 ON (RQ.RQSEL."D_KEYID" = R1."D_KEYID")
WHERE
RQ.RQSEL.WO_WORD = 'CIVILES' AND R1.WO_WORD = 'ADMIN'

it should work.

Luc.