簡體   English   中英

postgresql 空數組

[英]postgresql empty array

我在 PostgreSQL 中有下表:

   Column    |          Type          |                         Modifiers
-------------+------------------------+-----------------------------------------------------------
 description | text                   | not null
 sec_r       | integer[]              |

我的兩個整數數組sec_r有一些字段具有“空”值,但我猜它不是 null?

每當我嘗試select * from this table where sec_r = null我得到 0 行。

|  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)

但是,從 TheTable where 1 = ANY (sec_r) 執行 select * 會返回正確的行。

我如何 select 數組為空白的行?

您應該在 SQL 中使用IS NULL而不是= NULL NULL。

嘗試:

SELECT * FROM the_table WHERE sec_r IS NULL

您正在尋找IS NULL。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM