Skip site navigation (1) Skip section navigation (2)

Re: Performing antijoin in postgres

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Suresh_" <suiyengar(at)yahoo(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Performing antijoin in postgres
Date: 2007-08-31 09:36:13
Message-ID: 87wsvc11wy.fsf@oxford.xeocode.com (view raw or flat)
Thread:
Lists: pgsql-hackers
"Suresh_" <suiyengar(at)yahoo(dot)com> writes:

> I want to add an antijoin operator to PostgreSql.  

I think you can already do what you want like this:

SELECT *
  FROM A FULL OUTER JOIN B ON (x=y)
 WHERE x IS NULL
    OR y IS NULL

So for example:

postgres=# select * from a;
 i 
---
 1
 2
(2 rows)

postgres=# select * from b;
 i 
---
 2
 3
(2 rows)

postgres=# select * from a full outer join b on (a.i=b.i) where a.i is null or b.i is null;
 i | i 
---+---
 1 |  
   | 3
(2 rows)

-- 
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com

In response to

Responses

pgsql-hackers by date

Next:From: Jan WieckDate: 2007-08-31 12:08:43
Subject: Re: [GENERAL] Undetected corruption of table files
Previous:From: Peter EisentrautDate: 2007-08-31 09:16:40
Subject: Re: [HACKERS] broken doc

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group