[SQL] Check a column value not in Array.
Greetings, May I know the command to check whether a column value is in array please? For example, I am looking for sth like: select * from test where test.col not in ARRAY['val1', 'val2']; Thanks! -- Sent via pgsql-sql mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
Re: [SQL] Check a column value not in Array.
Hello 2008/8/14 Emi Lu <[EMAIL PROTECTED]>: > Greetings, > > May I know the command to check whether a column value is in array please? > > For example, I am looking for sth like: > > select * > from test > where test.col not in ARRAY['val1', 'val2']; > > Thanks! postgres=# select 1 = any(array[1,2,3]); ?column? -- t (1 row) postgres=# select 4 = any(array[1,2,3]); ?column? -- f (1 row) Regards Pavel Stehule > > -- > Sent via pgsql-sql mailing list ([email protected]) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql > -- Sent via pgsql-sql mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
Re: [SQL] Check a column value not in Array.
2008/8/14 Emi Lu <[EMAIL PROTECTED]>: > Greetings, > > May I know the command to check whether a column value is in array please? > > For example, I am looking for sth like: > > select * > from test > where test.col not in ARRAY['val1', 'val2']; > select * from test where test.col <> ALL ( ARRAY['val1', 'val2'] ); see http://www.postgresql.org/docs/current/static/functions-comparisons.html be careful with NULLs in this type of comparisons. -- Filip RembiaĆkowski -- Sent via pgsql-sql mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
