SQL state: 42P01

From: "David Monarchi" <david(dot)e(dot)monarchi(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: SQL state: 42P01
Date: 2008-01-15 00:00:03
Message-ID: eea51fdb0801141600x6c691942m6bb44f8b9ffc0083@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

PG 8.2
Red Hat Linux

Hello -

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.

And when I execute this query
select domain_name_dom, word_wdl, count_ofi, total_quality_ofi,
avg_quality_ofi
from zzz_brand2domain_step1_bs1 as B join
(select * from offpagedomainwordintersection_ofi
where B.domain_name_dom = domain_ofi
and B.word_wdl = word_ofi
and total_quality_ofi >= 5900) as A
on (domain_name_dom = A.domain_ofi
and word_wdl = A.word_ofi)
limit 10;

I receive this error message
ERROR: invalid reference to FROM-clause entry for table "b"
LINE 4: where B.domain_name_dom = domain_ofi
^
HINT: There is an entry for table "b", 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. Any assistance would be greatly appreciated.

Thank you.

David

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2008-01-15 00:27:19 Re: SQL state: 42P01
Previous Message LWATCDR 2008-01-14 19:31:13 Re: Avoiding a seq scan on a table.