How to determine if NULL is contained in an array in Postgres?

前端 未结 5 1168
耶瑟儿~
耶瑟儿~ 2021-01-01 15:41

How do I determine if NULL is contained in an array in Postgres? Currently using Postgres 9.3.3.

If I test with the following select it returns contains_null =

5条回答
  •  时光取名叫无心
    2021-01-01 16:31

    It seems the following works fine in PostgreSQL 10.1.

    CREATE TABLE my_table
    (
        ...
        my_set  int[] NOT NULL,
        ...
    );
    
    SELECT
        my_set
    FROM
        my_table
    WHERE
        array_position(my_set, NULL) IS NOT NULL;
    

提交回复
热议问题