Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Ambiguous column reference
Mon, Mar 19 2007 9:55 PMPermanent Link

"Ole Willy Tuv"
create table t1 (col1 integer, col2 varchar(10));
insert into t1 values (1,'Guilty');

create table t2 (col1 integer, col2 varchar(10));
insert into t2 values (1,'Not guilty');

select col2
from t1
join t2 on t2.col1 = t1.col1

The col2 reference in the select list is ambiguous and should raise an
error, since there are more than 1 column in the table expression with the
same unqualified column name.

I don't think the database engine should make the decision whether the
verdict is "Guilty" or "Not guilty" Smile

Ole Willy Tuv

Tue, Mar 20 2007 5:02 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ole,

<< The col2 reference in the select list is ambiguous and should raise an
error, since there are more than 1 column in the table expression with the
same unqualified column name. >>

This is in the same category as the GROUP BY issue.  EDB references the
columns in left-to-right table order according to the FROM clause, like
DBISAM.

I think some of these items might be candidates for a general
"SQLCompatibilityMode" type of property at the TEDBEngine or TEDBSession
level.

--
Tim Young
Elevate Software
www.elevatesoft.com


Tue, Mar 20 2007 6:02 PMPermanent Link

"Walter Matte"
I know MSSql would raise an issue on a query like this.  I would agree that
one should not assume.

And it would probably save a lot of time debugging if you did not specify
and the engine selected and it was not the one intended.

My 2 cents.

(Ole - I like the example... lol).

Walter


"Ole Willy Tuv" <owtuv@online.no> wrote in message
news:65B8714F-E9DF-4E40-B5E4-2B7E58CA622C@news.elevatesoft.com...
> create table t1 (col1 integer, col2 varchar(10));
> insert into t1 values (1,'Guilty');
>
> create table t2 (col1 integer, col2 varchar(10));
> insert into t2 values (1,'Not guilty');
>
> select col2
> from t1
> join t2 on t2.col1 = t1.col1
>
> The col2 reference in the select list is ambiguous and should raise an
> error, since there are more than 1 column in the table expression with the
> same unqualified column name.
>
> I don't think the database engine should make the decision whether the
> verdict is "Guilty" or "Not guilty" Smile
>
> Ole Willy Tuv
>
>

Wed, Mar 21 2007 9:11 AMPermanent Link

"Ole Willy Tuv"
Walter,

<< I know MSSql would raise an issue on a query like this.  I would agree
that one should not assume. >>

Not only SQL Server, most all well-known database engines raise an exception
on ambiguous column references.

Ole Willy Tuv

Image