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

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 (view raw or flat)
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

pgsql-sql by date

Next:From: Craig RingerDate: 2008-05-22 15:35:19
Subject: Re: Substract queries
Previous:From: Nacef LABIDIDate: 2008-05-22 15:15:12
Subject: Substract queries

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