Friday, July 23, 2010

Postgres array

select * from company where company_code in ('103','001')

select * from company where company_code = any(array['103','001'])

select * from company where company_code = any( regexp_split_to_array('103,001', ',') )

-- very neat, no need to to split string to array, can cast string directly to array, as long there's curly bracket inside
select * from company where company_code = any('{103,001}'::text[])


No comments:

Post a Comment