Search Postgresql Archives

Re: why isn't this subquery wrong?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 20, 2017 at 3:17 PM, jonathan vanasco <postgres@xxxxxxxx> 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.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux