2017-01-02 46 views
0

運行選擇查詢,我正在上H2數據庫查詢示例如下所述的問題 -擁有而在H2數據庫

select count(*) from Employee where employee_name is not null; 

但問題是H2是不支持is not null,請建議什麼可能是替代這個。

+0

檢查此:http://stackoverflow.com/questions/11672498/adding-the-not-null-constraint-to-an-sql-column – Uzair

+0

H2絕對支持'不是空'。什麼是你得到的錯誤信息? –

回答

0

試試這個

select count(*) from Employee 

WHERE employee_name = ? or (employee_name is null and ? is null); 

表達employee_name IS NULL返回TRUE如果變量employee_name的值爲NULL, 否則返回FALSE。