Re: BUG #9278: Error: SQLSTATE[42702]: Ambiguous column: 7 ERROR: column reference "tid" is ambiguous LINE 8: ... - Mailing list pgsql-bugs

From Michael Paquier
Subject Re: BUG #9278: Error: SQLSTATE[42702]: Ambiguous column: 7 ERROR: column reference "tid" is ambiguous LINE 8: ...
Date
Msg-id CAB7nPqT3nebj5MXWCXjW_RwByRQ497T-2BgPE-JXfnbR-BYWgA@mail.gmail.com
Whole thread Raw
In response to BUG #9278: Error: SQLSTATE[42702]: Ambiguous column: 7 ERROR: column reference "tid" is ambiguous LINE 8: ...  (tonimueller.unihalle@gmail.com)
List pgsql-bugs
On Thu, Feb 20, 2014 at 1:49 AM,  <tonimueller.unihalle@gmail.com> wrote:
> SQLSTATE[42702]: Ambiguous column: 7 ERROR: column reference "tid" is
> ambiguous LINE 8: ... taxonomy_term_data_name, taxonomy_term_data_vid, tid,
> taxon... ^

I am not seeing any bug here. This error is usually found because of
some bad naming in queries involving joins like this one:
=# create table aa (tid int);
CREATE TABLE
=# create table bb (tid int);
CREATE TABLE
=# select tid from aa,bb where aa.tid = bb.tid;
ERROR:  42702: column reference "tid" is ambiguous
LINE 1: select tid from aa,bb where aa.tid = bb.tid;
               ^
LOCATION:  colNameToVar, parse_relation.c:612

You should complete the SELECT clause with some alias like that:
=# select aa.tid from aa,bb where aa.tid = bb.tid;
 tid
-----
(0 rows)
Or that:
=# select bb.tid from aa,bb where aa.tid = bb.tid;
 tid
-----
(0 rows)
Regards,
--
Michael

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #9210: PostgreSQL string store bug? not enforce check with correct characterSET/encoding
Next
From: Noah Misch
Date:
Subject: Re: BUG #9210: PostgreSQL string store bug? not enforce check with correct characterSET/encoding