Re: WHERE IN for JOIN subquery?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Dave Johansen <davejohansen(at)gmail(dot)com>
Cc: pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: WHERE IN for JOIN subquery?
Date: 2017-12-19 00:10:34
Message-ID: CAKFQuwYAESXM2x-jz4bgxcC20io9mh+x+Z0TjTAbaaZcbn3aWQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, Dec 18, 2017 at 5:00 PM, Dave Johansen <davejohansen(at)gmail(dot)com>
wrote:

>
> other = a.other
> But I get this error:
> ERROR: invalid reference to FROM-clause entry for table "a"
>
> LINE 1: ...ue), COUNT(DISTINCT value) FROM other WHERE other=a.other GR...
>
> HINT: There is an entry for table "a", but it cannot be referenced from
> this part of the query.
>

One possible solution to this error is to add the word "LATERAL" before
LEFT JOIN so that the right side of the join can reference variables from
the left side.

David J.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Dave Johansen 2017-12-19 00:29:15 Re: WHERE IN for JOIN subquery?
Previous Message Dave Johansen 2017-12-19 00:00:05 WHERE IN for JOIN subquery?