Re: Substract queries

From: "Robins Tharakan" <tharakan(at)gmail(dot)com>
To: "Nacef LABIDI" <nacef(dot)l(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Substract queries
Date: 2008-05-22 15:27:15
Message-ID: 36af4bed0805220827m1fb61247o62efcd48851f7d99@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Probably you are looking for EXCEPT.

SELECT * FROM Tbl1 WHERE a=1
EXCEPT
SELECT * FROM tbl2 WHERE a=1 and b=1;

http://www.postgresql.org/docs/8.3/interactive/sql-select.html

Regards,
*Robins Tharakan*

---------- Forwarded message ----------
From: Nacef LABIDI <nacef(dot)l(at)gmail(dot)com>
Date: Thu, May 22, 2008 at 8:45 PM
Subject: [SQL] Substract queries
To: pgsql-sql(at)postgresql(dot)org

Hi all,

I was wondering how can I substract result between select queries. I mean I
want to issue a query that does this :
(select * from mytable where condition1) - (select * from mytable where
condition2)

Thanks to all

Nacef

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Craig Ringer 2008-05-22 15:35:19 Re: Substract queries
Previous Message Nacef LABIDI 2008-05-22 15:15:12 Substract queries