加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql 比较语句 IS DISTINCT FROM

发布时间:2020-12-13 17:12:11 所属栏目:百科 来源:网络整理
导读:Postgresql 支持两个特有的比较语句 IS DISTINCT FROM 和 IS NOT DISTINCT FROM,他们认为NULL是已知的值,而不是未知值。他们的比较和 != 不同。 看例子: postgres=#selecta,b,aisdistinctfrombas"distinctfrom",a!=bas"!="postgres-#frompostgres-#(value

Postgresql 支持两个特有的比较语句 IS DISTINCT FROM 和 IS NOT DISTINCT FROM,他们认为NULL是已知的值,而不是未知值。他们的比较和 != 不同。

看例子:

postgres=#selecta,b,aisdistinctfrombas"distinctfrom",a!=bas"!="
postgres-#from
postgres-#(values(1),(2),(NULL))asa(a),postgres-#(values(1),(NULL))asb(b);
a|b|distinctfrom|!=
---+---+---------------+----
1|1|f|f
1|2|t|t
1||t|
2|1|t|t
2|2|f|f
2||t|
|1|t|
|2|t|
||f|
(9rows)

通过例子得知:

1 is distinct from 1 返回false,1 != 1返回false。

1 is distinct from 2 返回true,1 != 1返回true。

1 is distinct from null 返回true,1 != null返回null。

null is distinct from null 返回false,null != null 返回null。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读