Check if NULL exists in Postgres array

前端 未结 4 798
既然无缘
既然无缘 2020-12-03 17:43

Similar to this question, how can I find if a NULL value exists in an array?

Here are some attempts.

SELECT num, ar, expected,
  ar @> ARRAY[NULL]         


        
4条回答
  •  天命终不由人
    2020-12-03 18:33

    I use this

    select 
        array_position(array[1,null], null) is not null
    

    array_position - returns the subscript of the first occurrence of the second argument in the array, starting at the element indicated by the third argument or at the first element (array must be one-dimensional)

提交回复
热议问题