Subject Re: sql problem
Author Svein Erling
I think your sql is ambiguous and am surprised that Firebird doesn't
reject it due to syntax. If you use two or more occurences of a table
within a query, you should alias both of them. Why? Simply because
both of them will respond to the name of the table. E.g. when
selecting CONTACT_SALUTATION.NAME, Firebird may choose to select that
from the table not being aliased or the one being aliased. Hence,
change your query to

SELECT
CONTACT.PK,
Y.NAME,
X.NAME AS XX
FROM
CONTACT
LEFT OUTER JOIN CONTACT_SALUTATION Y ON (CONTACT.FK_1 = Y.PK)
LEFT OUTER JOIN CONTACT_SALUTATION X ON (CONTACT.FK_FK2 = X.PK)

Note that I only answer this because the SQL confused me, I have not
yet tried Firebird 1.5 (I'm still on 1.0.2 for a little while longer)
and your problem may well be due to something completely different
that I simply didn't notice. But when programmers are confused, it is
a good starting point for understanding why the database gets things
wrong.

HTH,
Set

--- In firebird-support@yahoogroups.com, "frische_brise2003" wrote:
> My query:
> SELECT
> CONTACT.PK,
> CONTACT_SALUTATION.NAME,
> X.NAME AS XX
> FROM
> CONTACT
> LEFT OUTER JOIN CONTACT_SALUTATION ON (CONTACT.FK_1 =
> CONTACT_SALUTATION.PK)
> LEFT OUTER JOIN CONTACT_SALUTATION X ON (CONTACT.FK_FK2 = X.PK)
>
> What am I doing wrong? _ Is the syntax of my query incorrect?