Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PostgreSQL为NULL,长度为_Sql_Postgresql_Null_String - Fatal编程技术网

PostgreSQL为NULL,长度为

PostgreSQL为NULL,长度为,sql,postgresql,null,string,Sql,Postgresql,Null,String,我试图从一个特定列为空的表中获取所有记录。但我没有任何记录。另一方面,有许多记录的长度(字段)实际上为0 select count(*) from article a where length(for_interest) =0; count ------- 9 (1 row) select count(*) from article a where for_interest is NULL ; count ------- 0 (1 row) 关于NULLs的事我没

我试图从一个特定列为空的表中获取所有记录。但我没有任何记录。另一方面,有许多记录的长度(字段)实际上为0

select count(*) from article a where length(for_interest) =0;
 count 
-------
     9
(1 row)

select count(*) from article a where for_interest is NULL ;
 count 
-------
     0
(1 row)
关于NULLs的事我没弄好?更多信息

select count(*) from article AS a where for_interest is NOT NULL ;
 count 
-------
    15
(1 row)

select count(*) from article ;
 count 
-------
    15
(1 row)
PostgreSQL版本是9.3.2

添加样本数据、表描述等(仅为此创建了2条记录的新样本表)

可以保存空字符串
'
,它不是一个
NULL
值。
空字符串的长度为0。
NULL
值的长度为
NULL

对于
NULL
输入,大多数函数返回
NULL

SELECT length('');   --> 0
SELECT length(NULL); --> NULL

SELECT NULL IS NULL; --> TRUE
SELECT '' IS NULL;   --> FALSE

您的表在for_interest中的值为空。这对我有用。
从文章中选择count(*),其中for_interest为空。
因此,请在您的表中选择示例数据,并显示您的表结构编辑的问题以及信息显示表结构。您是否在创建表中设置了标注非空约束
SELECT length('');   --> 0
SELECT length(NULL); --> NULL

SELECT NULL IS NULL; --> TRUE
SELECT '' IS NULL;   --> FALSE