Re: select multiple immediate values, but in multiple rows

From: Richard Huxton <dev(at)archonet(dot)com>
To: lucap(at)personainternet(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: select multiple immediate values, but in multiple rows
Date: 2005-03-15 08:18:59
Message-ID: 42369A73.3050502@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Luca Pireddu wrote:
> Hello all. I'd like to write a query does a set subtraction A - B, but A is
> is a set of constants that I need to provide in the query as immediate
> values. I thought of something like
>
> select a from (1,2,3.4)
> except
> select col_name from table;

richardh=> SELECT * FROM foo;
a
---
1
2
3
(3 rows)

richardh=> SELECT * FROM foo WHERE a NOT IN (1,2);
a
---
3
(1 row)

Run some tests with nulls in the column and the constant list too so you
understand what happens in those cases.

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Robert.Farrugia 2005-03-15 09:00:14 Re: Inserting values in arrays
Previous Message Richard Huxton 2005-03-15 08:08:46 Re: Inserting values in arrays