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

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Reply via email to