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 23:16:56 |
Message-ID: | CAKFQuwY4o3G323LtKe_NWjBA+TEE99J01=w17vcdEcB=yZwOXA@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:
>
> SELECT foo_id
> FROM example_a__data
> WHERE foo_id IN (SELECT bar_id FROM example_a__rollup)
> ;
>
>
>
Or write it the idiomatic way (i.e., as a proper semi-join):
SELECT foo_id
FROM example_a__data
WHERE EXISTS (SELECT 1
FROM example_a__rollup
WHERE example_a__rollup.bar_id =
example_a__data.foo_id)
IME its harder to forget the table prefix when using this form.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2017-04-21 00:04:32 | Re: why isn't this subquery wrong? |
Previous Message | Steve Crawford | 2017-04-20 23:02:22 | Re: why isn't this subquery wrong? |