开发者

postgresql empty array

开发者 https://www.devze.com 2023-03-11 10:00 出处:网络
I have the following table in PostgreSQL: Column|开发者_JS百科Type|Modifiers -------------+------------------------+-----------------------------------------------------------

I have the following table in PostgreSQL:

   Column    |       开发者_JS百科   Type          |                         Modifiers
-------------+------------------------+-----------------------------------------------------------
 description | text                   | not null
 sec_r       | integer[]              |

My two array of integers sec_r have some fields that have "null" values, but I guess it isn't null?

Whenever I try to select * from this table where sec_r = null I get 0 rows.

|  description     |  sec_r  |
+------------------+---------+
| foo bar foo bar  |         |
| foo bar foo bar  | {1,2,3} |
| foo bar foo bar  |         |
| foo bar foo bar  | {9,5,1} |
(4 rows)

Doing select * from TheTable where 1 = ANY (sec_r) returns the correct rows however.

How do I select the rows where the array is blank?


You should use IS NULL and not = NULL in SQL.

Try:

SELECT * FROM the_table WHERE sec_r IS NULL


you are looking for IS NULL.

0

精彩评论

暂无评论...
验证码 换一张
取 消