【发布时间】:2017-01-02 11:56:44
【问题描述】:
我正在 H2 数据库上运行示例查询,如下所述 -
select count(*) from Employee where employee_name is not null;
但问题是 H2 不支持 is not null,请提出替代方案。
【问题讨论】:
-
H2 绝对支持
is not null。你得到的错误信息到底是什么?
我正在 H2 数据库上运行示例查询,如下所述 -
select count(*) from Employee where employee_name is not null;
但问题是 H2 不支持 is not null,请提出替代方案。
【问题讨论】:
is not null。你得到的错误信息到底是什么?
试试这个
select count(*) from Employee
WHERE employee_name = ? or (employee_name is null and ? is null);
如果变量employee_name 的值为NULL,则表达式employee_name IS NULL 返回TRUE, 否则返回 FALSE。
【讨论】: