Re: Can't join on null values - Mailing list pgsql-bugs

From Peter Eisentraut
Subject Re: Can't join on null values
Date
Msg-id 200407072125.21247.peter_e@gmx.net
Whole thread Raw
In response to Can't join on null values  (David Newall <davidn-postgres@rebel.net.au>)
List pgsql-bugs
David Newall wrote:
> PostgreSQL version:  7.4.3 (RPMs from ftp.au.postgresql.org)
>
> Operating Sysem: Fedora Core 1
>
> CREATE TABLE t1 (i INTEGER, j INTEGER);
> INSERT INTO t1 VALUES (1, NULL);
> CREATE TABLE t2 AS SELECT * FROM t1;
> SELECT * FROM t1 JOIN t2 USING (i, j);
>  i | j
> ---+---
> (0 rows)
>
> I believe the one row, which is identically present in both table,
> should be selected.  The problem occurs because of the NULL value.

A join happens when two values are equal in the sense of the operator =.
But "NULL = NULL" is not true, so the behavior is correct.

pgsql-bugs by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: UNIQUE not honoured for NULL
Next
From: Stephan Szabo
Date:
Subject: Re: UNIQUE not honoured for NULL