【PostgreSQL】配列の値で抽出する(Where、any)

PostgreSQL構文

where文で配列を使う

配列の中のいずれかの値で検索をするには、any(配列)を使います。

※ 配列の中の値どれかに合致すれば、その行が取得できます。

-- 構文
select * from テーブル名 where 列名 = any(配列);

-- 例
select * from m_school where seq = any(array[1,2,3]);                -- 数値
select * from m_school where school_code = any(array['A','B','C']);  -- 文字
select * from m_school where start_date 
= any(array[cast('2021/5/1' as date),cast('2021/5/3' as date)]);     -- 日付