missing FROM-clause entry for table

Lists: pgsql-general
From: Erwin Moller <erwin(at)darwine(dot)nl>
To: pgsql-general(at)postgresql(dot)org
Subject: missing FROM-clause entry for table
Date: 2008-11-12 18:08:03
Message-ID: 491B1B83.5090705@darwine.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi group,

I get a mysterious errormessage while executing the following query:
(I left the tabledefinitions out, since I think they don't matter. If I
am wrong I'll be happy to post them.)

SELECT DRV1.languageid, DRV1.categorypropertyid,
CPL.categorypropertylangname
FROM (SELECT L.languageid, CP.categorypropertyid FROM tbllanguage AS L,
tblcategoryproperty AS CP) AS DRV1
LEFT OUTER JOIN tblcategorypropertylang AS CPL ON
((CLP.languageid=DRV1.languageid) AND
(CPL.categorypropertyid=DRV1.categorypropertyid));

ERROR: missing FROM-clause entry for table "clp"

While this one is working just fine:

SELECT DRV1.languageid, DRV1.categorypropertyid, categorypropertylangname
FROM (SELECT L.languageid, CP.categorypropertyid FROM tbllanguage AS
L, tblcategoryproperty AS CP) AS DRV1
LEFT OUTER JOIN tblcategorypropertylang ON
((tblcategorypropertylang.languageid=DRV1.languageid) AND
(tblcategorypropertylang.categorypropertyid=DRV1.categorypropertyid));

The only difference is that I didn't use an alias CPL for
tblcategorypropertylang.
(The above queries are dynamically created by PHP based on a lot of
other, not related, things, and I would like to use the first way
because that makes sense in my current project.)

I Googled a little for the errormessage, but to no avail.
The second query is also good enough for me, but I am curious what I am
missing here.

What is causing this?

Thanks for your time.

Regards,
Erwin Moller


From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: Erwin Moller <erwin(at)darwine(dot)nl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: missing FROM-clause entry for table
Date: 2008-11-12 18:20:09
Message-ID: 491B1E59.8090002@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 12/11/2008 18:08, Erwin Moller wrote:
> LEFT OUTER JOIN tblcategorypropertylang AS CPL ON
> ((CLP.languageid=DRV1.languageid) AND
> (CPL.categorypropertyid=DRV1.categorypropertyid));
>
> ERROR: missing FROM-clause entry for table "clp"

You've a typo in the query - the table alias is CPL, not CLP.

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod(at)iol(dot)ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------


From: Adrian Klaver <aklaver(at)comcast(dot)net>
To: Erwin Moller <erwin(at)darwine(dot)nl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: missing FROM-clause entry for table
Date: 2008-11-12 18:23:49
Message-ID: 656120527.109621226514229632.JavaMail.root@sz0030a.emeryville.ca.mail.comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

----- "Erwin Moller" <erwin(at)darwine(dot)nl> wrote:

> Hi group,
>
> I get a mysterious errormessage while executing the following query:
> (I left the tabledefinitions out, since I think they don't matter. If
> I
> am wrong I'll be happy to post them.)
>
> SELECT DRV1.languageid, DRV1.categorypropertyid,
> CPL.categorypropertylangname
> FROM (SELECT L.languageid, CP.categorypropertyid FROM tbllanguage AS
> L,
> tblcategoryproperty AS CP) AS DRV1
> LEFT OUTER JOIN tblcategorypropertylang AS CPL ON
> ((CLP.languageid=DRV1.languageid) AND
^^^ instead of CPL

> (CPL.categorypropertyid=DRV1.categorypropertyid));
>
> ERROR: missing FROM-clause entry for table "clp"
>
> While this one is working just fine:
>
> SELECT DRV1.languageid, DRV1.categorypropertyid,
> categorypropertylangname
> FROM (SELECT L.languageid, CP.categorypropertyid FROM tbllanguage
> AS
> L, tblcategoryproperty AS CP) AS DRV1
> LEFT OUTER JOIN tblcategorypropertylang ON
> ((tblcategorypropertylang.languageid=DRV1.languageid) AND
> (tblcategorypropertylang.categorypropertyid=DRV1.categorypropertyid));
>
> The only difference is that I didn't use an alias CPL for
> tblcategorypropertylang.
> (The above queries are dynamically created by PHP based on a lot of
> other, not related, things, and I would like to use the first way
> because that makes sense in my current project.)
>
> I Googled a little for the errormessage, but to no avail.
> The second query is also good enough for me, but I am curious what I
> am
> missing here.
>
> What is causing this?
>
> Thanks for your time.
>
> Regards,
> Erwin Moller
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

Adrian Klaver
aklaver(at)comcast(dot)net


From: Erwin Moller <erwin(at)darwine(dot)nl>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: missing FROM-clause entry for table
Date: 2008-11-12 18:30:36
Message-ID: 491B20CC.60507@darwine.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Raymond O'Donnell schreef:
> On 12/11/2008 18:08, Erwin Moller wrote:
>
>> LEFT OUTER JOIN tblcategorypropertylang AS CPL ON
>> ((CLP.languageid=DRV1.languageid) AND
>> (CPL.categorypropertyid=DRV1.categorypropertyid));
>>
>> ERROR: missing FROM-clause entry for table "clp"
>>
>
> You've a typo in the query - the table alias is CPL, not CLP.
>
Oh my....
/me slaps head against the wall.
And I checked that query 2 times before posting here....

Maybe it is time to call it a day. ;-)

Thanks Ray! (And Adrian)

Regards,
Erwin Moller
> Ray.
>
> ------------------------------------------------------------------
> Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
> rod(at)iol(dot)ie
> Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
> ------------------------------------------------------------------
>
>
>