Re: invalid reference to FROM-clause entry for table - Mailing list pgsql-sql

From Tom Lane
Subject Re: invalid reference to FROM-clause entry for table
Date
Msg-id 472955.1727994092@sss.pgh.pa.us
Whole thread Raw
In response to invalid reference to FROM-clause entry for table  (Sam Stearns <sam.stearns@dat.com>)
List pgsql-sql
Sam Stearns <sam.stearns@dat.com> writes:
> This one is really doing my head in:
>   ...
>   FROM (pud_fme_data d
>         inner join csbuser u on (u.userid=d.user_id)
>         inner join office o on (u.officeid=o.officeid)
>         left outer join login l on (l.userid=u.userid) ) alias6;

> ERROR:  invalid reference to FROM-clause entry for table "o"
> LINE 2:     o.crmaccountid AS crm_account_id,
>             ^
> DETAIL:  There is an entry for table "o", but it cannot be referenced from
> this part of the query.

IIRC, the join alias "alias6" hides any table aliases inside it.
Leave that off.  Or reference the column as "alias6.crmaccountid".
(This way might require fooling around with column aliases so that
crmaccountid is a unique column name within that scope.)

            regards, tom lane



pgsql-sql by date:

Previous
From: Sam Stearns
Date:
Subject: invalid reference to FROM-clause entry for table
Next
From: "David G. Johnston"
Date:
Subject: Re: invalid reference to FROM-clause entry for table