Sybase sql語句報 void type 錯誤

遇到一個問題:
Sybase數據,查詢當給一個null起別名之後,再根據這個字段過濾是否爲null會有報錯。
sql語句爲:
select * from (select null as test from TestTable) t  where  test is null 

報錯信息:
10:56:00  [SELECT - 0 row(s), 0.000 secs]  [Error Code: 403, SQL State: ZZZZZ]  Invalid operator for datatype op: is null type: VOID TYPE.
... 1 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.000/0.000 sec [0 successful, 0 warnings, 1 errors]



解決方法:
使用convert函數轉換字段就可以了。
select * from (select null as test from TestTable) t  where  test is null convert(varchar(15),test) is null
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章