Skip site navigation (1) Skip section navigation (2)

Re: SQL state: 42P01

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David Monarchi" <david(dot)e(dot)monarchi(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: SQL state: 42P01
Date: 2008-01-15 00:27:19
Message-ID: 9252.1200356839@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
"David Monarchi" <david(dot)e(dot)monarchi(at)gmail(dot)com> writes:
> When I execute the following query,
> select A.domain_name_dom, A.word_wdl, A.count_ofi, A.total_quality_ofi,
> A.avg_quality_ofi
>   from zzz_brand2domain_step2_bs2 as A join
>         (select B.domain_ofi, B.word_ofi, B.count_ofi, B.total_quality_ofi,
> B.avg_quality_ofi
>            from offpagedomainwordintersection_ofi as B
>              where B.domain_ofi != A.domain_name_dom
>              order by B.total_quality_ofi desc
>              limit 1) as C
>          on A.word_wdl = B.word_ofi;

> I receive this error message
> ERROR:  invalid reference to FROM-clause entry for table "a"
> LINE 5:              where B.domain_ofi != A.domain_name_dom
>                                            ^
> HINT:  There is an entry for table "a", but it cannot be referenced from
> this part of the query.

> I don't understand why I can't reference the respective tables in the
> queries.

Because a JOIN happens between two *independent* tables.  The above
isn't well-defined.

			regards, tom lane

In response to

Responses

pgsql-novice by date

Next:From: Cedric BUSCHINIDate: 2008-01-15 08:28:45
Subject: - Automatically insertion
Previous:From: David MonarchiDate: 2008-01-15 00:00:03
Subject: SQL state: 42P01

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group