Subject Re: [ib-support] Re: Ambiguous query or bug ?
Author Claudio Valderrama C.
""dianeb77x"" <dianeb77@...> wrote in message
news:9ula7n+p9mu@......
> --- In ib-support@y..., "Claudio Valderrama C." <cvalde@u...> wrote:
> > ""B=E9ru"" <beru@m...> wrote in message
> > news:9ufmae+6h8p@e...
> > > JJM posted the following problem on the french IB newsgroup:
> > >
> > > > SELECT RQSEL.D_KEYID
> > > > FROM RQSEL
> > > > INNER JOIN RQSEL R1
> > > > ON (RQSEL."D_KEYID" =3D R1."D_KEYID")
> > > > WHERE
> > > > (RQSEL.WO_WORD =3D 'CIVILES' AND R1.WO_WORD =3D 'ADMIN')
> >=20
> > It's ambiguous: one of the table instances is not qualified, so what=20
> should
> > the engine use? When a table appears twice, both places should carry=20
> an
> > alias. Otherwise, results are almost random.
>
> What's ambiguous here? One instance is "RQSEL", the other is "R1".=20=20
> As far as I can see, all column references are qualified with one name=20
> or the other.
> What's not to like?

Diane, please be clear: if the alias takes precedence over the table name,
how the h*ll is the engine going to assume that in one case it should use
the original table name and in the other case, it should use the alias? This
is totally confusing at least, but I don't expect more from SQL.
Furthermore, I've seen code that often uses the name and the alias without
care, so really allowing this in a join is opening a Big Can Of Worms.
Whatever Mr Melton has to say, this is ambiguous from common sense
perspective. I wouldn't allow it in any case.

C.
--
Claudio Valderrama C. - http://www.cvalde.com - http://www.firebirdSql.org
Independent developer
Owner of the Interbase® WebRing