is [not] distinct from 的 null 比较
来源:互联网 发布:网站编辑软件 编辑:程序博客网 时间:2024/06/05 19:05
--在postgresql中经常会比较两个值相同或者不同,但如果比较表达中有一个为null则会比较头痛,如下:
postgres=# select null <> null ,null = null ,null is null,null is not null;
?column? | ?column? | ?column? | ?column?
----------+----------+----------+----------
| | t | f
--创建测试数据
postgres=# create table t (id int,name varchar(20));
CREATE TABLE
postgres=# insert into t values(1,'rudy');
INSERT 0 1
postgres=# insert into t values(2);
INSERT 0 1
postgres=# select * from t;
id | name
----+------
1 | rudy
2 |
(2 rows)
--expression如果为null与任何值比较,都为null
postgres=# select * from t where null <> name;
id | name
----+------
(0 rows)
--is distinct from 对与非null其意为<>
postgres=# select * from t where 'rudy' is distinct from name;
id | name
----+------
2 |
--is distinct from 对于expression为null,其会让与null的对比为值,非null对比其本身为假,is distinct from本身比较其是否不同
postgres=# select * from t where null is distinct from name;
id | name
----+------
1 | rudy
(1 row)
--is not distinct from 对与非null其意为=
postgres=# select * from t where 'rudy' is not distinct from name;
id | name
----+------
1 | rudy
--is distinct from 对于expression为null,其会让与null的对比为值,非null对比其本身为假,is distinct from本身比较其是相同
postgres=# select * from t where null is not distinct from name;
id | name
----+------
2 |
--注意 is [not] distinct from 效率上不如<>,=所以尽量要少用
0 0
- is [not] distinct from 的 null 比较
- not in和select ** from is null
- is null && is not null
- NOT IN 与NULL的比较
- MySql中IS NOT NULL与!=NULL的区别
- SQL中IS NOT NULL与!=NULL的区别
- mysql <> null != null is not null
- oracle is null 和is not null
- is null 和 is not null
- is not mapped [from
- is not mapped [from ***]
- null, message from server: "Host ***" is not allowed to connect to this MySQL server"
- java.sql.SQLException: null, message from server: "Host 'xxx' is not allowed to connect
- java.sql.SQLException: null, message from server: "Host 'xxx' is not allowed to connect
- 远程mysql_java.sql.SQLException: null, message from server: "Host 'xxx' is not allowed to connect
- java.sql.SQLException: null, message from server: "Host 'xxx' is not allowed to connect
- java.sql.SQLException: null, message from server: "Host '192.168.1.101' is not allowed to connect
- java.sql.SQLException: null, message from server: "Host 'xxx' is not allowed to connect
- PHPExcel 使用帮助
- js编写的语法高亮引擎
- android 手机作为手写输入板
- CentOS服务器时间同步
- Viminum设置自己的快捷键
- is [not] distinct from 的 null 比较
- Android开发之Eclipse中使用git简单步骤
- 自定义 UIAlertView 之 BSYAlertView
- swift 快速奔跑的兔几 本节的内容是:重力和snap效果
- quartz集群调度机制调研及源码分析
- ios 图片压缩的两种方式
- 关于Eclipse Attach Source找不到源码的解决方法
- 监听黑名单电话, 短信的service
- SOJ 2113 数字游戏