Re: select multiple immediate values, but in multiple rows - Mailing list pgsql-sql

From Richard Huxton
Subject Re: select multiple immediate values, but in multiple rows
Date
Msg-id 42369A73.3050502@archonet.com
Whole thread Raw
In response to select multiple immediate values, but in multiple rows  (Luca Pireddu <lucap@shaw.ca>)
List 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


pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Inserting values in arrays
Next
From: Robert.Farrugia@go.com.mt
Date:
Subject: Re: Inserting values in arrays