Re: why isn't this subquery wrong?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: jonathan vanasco <postgres(at)2xlp(dot)com>
Cc: pgsql-general general <pgsql-general(at)postgresql(dot)org>
Subject: Re: why isn't this subquery wrong?
Date: 2017-04-20 22:42:06
Message-ID: CAKFQuwbecWp41+hxyeL8qxmtuu4S6bN2XNpw8_AOkWUCzu8PDg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Apr 20, 2017 at 3:17 PM, jonathan vanasco <postgres(at)2xlp(dot)com> wrote:

> postgres doesn't raise an error because example_a__data does have a bar_id
> -- but example_a__rollup doesn't and there's no explicit correlation in the
> query.
>
>
​Subqueries can see all columns of the parent. When the subquery actually
uses one of them it is called a "correlated subquery".

See another recent question on this topic for more details:

https://www.postgresql.org/message-id/20160714135233.1410.92538%40wrigleys.postgresql.org

Unfortunately at present everyone here seems content answering this on the
list semi-frequently instead of updating the docs and/or FAQ section of our
wiki. The topic is covered (I think...) but not easily found (I failed to
just now...) - and harder when you don't know what to call it in the first
place.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2017-04-20 22:43:50 Re: why isn't this subquery wrong?
Previous Message Steve Crawford 2017-04-20 22:38:02 Re: why isn't this subquery wrong?