Re: difference between EXCEPT and NOT IN?

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Raphael Bauduin <rblists(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: difference between EXCEPT and NOT IN?
Date: 2008-04-01 16:04:22
Message-ID: 20080401085733.F16796@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, 1 Apr 2008, Raphael Bauduin wrote:

> The 2 following statements don't give the same result. I expected the
> second ti give the exact same result as the first one.

If any entree_id can be NULL they aren't defined to give the same result.

EXCEPT is defined in terms of duplicates based on distinctness, and for
example (1 is distinct from 1) is false, (1 is distinct from NULL) is true
and (NULL is distinct from NULL) if false.

NOT IN is defined in terms of equality, and for example, (1=1) is true,
(1=NULL) is unknown and (NULL=NULL) is unknown.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Raphael Bauduin 2008-04-01 16:43:47 Re: difference between EXCEPT and NOT IN?
Previous Message Raphael Bauduin 2008-04-01 15:50:42 difference between EXCEPT and NOT IN?