Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.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 全部和空集=真_Postgresql - Fatal编程技术网

Postgresql 全部和空集=真

Postgresql 全部和空集=真,postgresql,Postgresql,如果所有类似操作(ALL(somesubquery))中的子查询返回空集,那么它将始终返回TRUE。这样:从某个表中选择*,其中TRUE=ALL(空集)。如何更改此行为?如果子查询位于: ALL (SELECT ...) 返回空集,结果为NULL: regress=> select all( SELECT true WHERE false ); bool ------ (1 row) 如果希望为true,则必须使用coalesce。由于语法限制,不能将all直接用作表达式,必须将

如果所有类似操作(ALL(somesubquery))中的子查询返回空集,那么它将始终返回TRUE。这样:从某个表中选择*,其中TRUE=ALL(空集)。如何更改此行为?

如果子查询位于:

ALL (SELECT ...)
返回空集,结果为
NULL

regress=> select all( SELECT true WHERE false );
 bool 
------

(1 row)
如果希望为true,则必须使用
coalesce
。由于语法限制,不能将
all
直接用作表达式,必须将其包装在子查询中,如:

regress=> select coalesce( (select all( SELECT true WHERE false )), true);
 coalesce 
----------
 t
(1 row)