Ambiguous field names in joins
Firebird rejects unqualified field names in a query if these field names exist in more than one dataset involved in a join.This is even true for inner equi-joins where the field name figures in the ON
clause like this:
select a, b, c
from TA
join TB on TA.a = TB.a;
There is one exception to this rule: with named columns joins and natural joins, the unqualified field name of a column taking part in the matching process may be used legally and refers to the merged column of the same name.For named columns joins, these are the columns listed in the USING
clause.For natural joins, they are the columns that have the same name in both relations.But please notice again that, especially in outer joins, plain colname
isn’t always the same as left.colname
or right.colname
.Types may differ, and one of the qualified columns may be NULL
while the other isn’t.In that case, the value in the merged, unqualified column may mask the fact that one of the source values is absent.