ERROR: missing FROM-clause entry for table

Started by Kevin Watersonabout 10 years ago2 messagesgeneral
Jump to latest
#1Kevin Waterson
kevin.waterson@gmail.com

I do not understand why I am getting this error.
I have joined the table correctly, is this not sufficient?

forge=> select * FROM generate_series('2016-01-22', '2017-12-31', '1
day'::interval) AS day
LEFT JOIN (
select *, generate_series(c.start_time,
c.end_time, '2 week'::interval) meeting
from call_schedule c
join call_durations cds on c.duration_id=cds.id
where call_frequency_id = 5
) c on ((day, '1 day'::interval) OVERLAPS (meeting,
cds.duration * '1s'::interval));
ERROR: missing FROM-clause entry for table "cds"
LINE 7: ...c on ((day, '1 day'::interval) OVERLAPS (meeting, cds.durati...

#2Vik Fearing
vik@postgresfriends.org
In reply to: Kevin Waterson (#1)
Re: ERROR: missing FROM-clause entry for table

On 02/21/2016 02:22 PM, Kevin Waterson wrote:

I do not understand why I am getting this error.
I have joined the table correctly, is this not sufficient?

forge=> select * FROM generate_series('2016-01-22', '2017-12-31', '1
day'::interval) AS day
LEFT JOIN (
select *, generate_series(c.start_time,
c.end_time, '2 week'::interval) meeting
from call_schedule c
join call_durations cds on
c.duration_id=cds.id <http://cds.id&gt;
where call_frequency_id = 5
) c on ((day, '1 day'::interval) OVERLAPS
(meeting, cds.duration * '1s'::interval));
ERROR: missing FROM-clause entry for table "cds"
LINE 7: ...c on ((day, '1 day'::interval) OVERLAPS (meeting, cds.durati...

Once you leave the subquery, cds ceases to exist. You need to add
something like cds.duration as cds_duration to your subquery's select
and then you can use c.cds_duration in your join clause.

Since your subquery already has *, if the column duration is not
ambiguous you can just join using c.duration but it's usually best to
only select the columns you need.
--
Vik Fearing +33 6 46 75 15 36
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general