Search Postgresql Archives

Re: (FAQ?) JOIN condition - 'WHERE NULL = NULL'

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

 



Ian Sillitoe wrote:
This is probably a stupid question that has a very quick answer, however it
would be great if someone could put me out of my misery...

I'm trying to JOIN two tables (well a table and a resultset from a PL/pgsql
function) where a joining column can be NULL
Sounds like you might want something like:

SELECT * FROM tablea INNER JOIN tableb ON (NOT tablea.id IS DISTINCT FROM tableb.tablea_id_fk);

which can also be written as:

SELECT * FROM tablea, tableb WHERE NOT tablea.id IS DISTINCT FROM tableb.tableid_id_fk ;

There's been lots of recent discussion of IS DISTINCT FROM, which is why it comes straight to mind.

If that's not what you meant (by NULL = NULL) then might you be looking for an OUTER JOIN ?

--
Craig Ringer

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[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