ISNULL函数
在MySQL中,ISNULL(expr)函数接收一个参数,并测试该参数是否为“NULL”。如果参数为“NULL”,则ISNULL函数返回“1”,否则返回“0”。可采用虚谷数据库的NVL函数进行替代。
- 基础表及数据
SQL> create table special_isnull (id int,start_date date default null ); SQL> insert into special_isnull(id,start_date) values(1,'2000-01-01'),(2,null);
- MySQL
SQL> select * from special_isnull where isnull(start_date); id|start_date| --+----------+ 2| |
- 虚谷数据库
SQL> select * from special_isnull where start_date is null; id|start_date| --+----------+ 2| | SQL> select * from special_isnull where nvl(start_date,null) is null; id|start_date| --+----------+ 2| |