Re: Select Rows With Only One of Two Values - Mailing list pgsql-general

From Chris Angelico
Subject Re: Select Rows With Only One of Two Values
Date
Msg-id CAPTjJmrb=KZmy-CWi8QzQgakD54RWa2+ZWcNbcw_KHJbmSFrXQ@mail.gmail.com
Whole thread Raw
In response to Re: Select Rows With Only One of Two Values  (Alban Hertroys <haramrae@gmail.com>)
List pgsql-general
On Sat, Jul 21, 2012 at 6:52 AM, Alban Hertroys <haramrae@gmail.com> wrote:
> I don't think the DISTINCT is necessary there, doesn't EXCEPT already return a distinct set, just like UNION (hence
theexistence of UNION ALL)? 
>
> It can also be written as a correlated subquery:

Oops, yes. I usually use UNION ALL and friends, and IMHO that "ALL"
keyword is one of SQL's weirder warts. Most of the time, a wordier
query involves more work (SELECT DISTINCT vs SELECT), but in this odd
instance, it's the other way around.

And yes, it can. Not sure whether the subquery or EXCEPT notation is
more readable. Much of a muchness, really.

ChrisA

pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: big database resulting in small dump
Next
From: Chris Angelico
Date:
Subject: Re: Pg_ctl promote -- wait for slave to be promoted fully ?