MapReduce服务 MRS-规则:HQL语法规则之判空

时间:2023-11-01 16:19:45

HQL语法规则之判空

判断字段是否为“空”,即没有值,使用“is null”;判断不为空,即有值,使用“is not null”。

要注意的是,在HQL中String类型的字段若是空字符串, 即长度为0,那么对它进行IS NULL的判断结果是False。此时应该使用“col = '' ”来判断空字符串;使用“col != '' ”来判断非空字符串。

正确示例:

select * from default.tbl_src where id is null;select * from default.tbl_src where id is not null;select * from default.tbl_src where name = '';select * from default.tbl_src where name != '';

错误示例:

select * from default.tbl_src where id = null;select * from default.tbl_src where id != null;select * from default.tbl_src where name is null;select * from default.tbl_src where name is not null;

注:表tbl_src的id字段为Int类型,name字段为String类型。

support.huaweicloud.com/devg3-mrs/mrs_07_450025.html