6.4.11:子查询
来源:互联网 发布:mac os x使用手册 编辑:程序博客网 时间:2024/06/05 04:39
如果底层数据库支持子查询,则可以在HQL语句中使用子查询。与SQL中子查询相似的是,HQL中的子查询也需要使用英文括号括起来,例如:
from Cat as fatcatwhere fatcat.weight>(select avg(cat.weight) from DomesticCat cat);与SQL子查询语法完全类似,如果子查询是多行结果集,则应该使用多行运算符,例如:
from Cat as catwhere not (cat.name,cat.color) in(select cat.name,cat.color from DomesticCat cat);from DomesticCat as catwhere cat.name not in(select name.nickName from Name as name);SQL语法中子查询还可以出现在select子句之后,HQL也支持这种用法,例如:
select cat.id,(select max(kit.weight) from cat.kitten kit)from Cat as cat;如果在select子查询后的列表中包含多项,则在HQL中需要使用一个元组构造符,例如:
from Cat as catwhere not (cat.name,cat.color) in(select cat.name,cat.color from DomesticCat cat);
- 6.4.11:子查询
- 子查询
- 子查询
- 子查询
- 子查询
- 子查询
- 子查询
- 子查询
- 子查询
- 子查询
- 子查询
- 子查询
- 子查询
- 子查询
- 子查询
- 子查询
- 子查询
- 子查询
- Java布局管理器(五)之BoxLayout布局管理
- lua 中调用函数特殊的写法(lua语言)
- Cocos2d-x中的Visual studio 2012环境搭建(懒人专用)
- 将SharePoint 2010的workflow custom activity升级到SharePoint 2013遇到的问题
- 使用NPOI操作Excel导入导出数据
- 6.4.11:子查询
- 构造函数
- Coursera Machine Leaning 课程总结
- 6.4.12:命名HQL查询
- CF 5 C. Longest Regular Bracket Sequence
- 替代Apache Ant的最佳工具
- 8 Deadly Commands You Should Never Run on Linux
- VMware vSphere 服务器虚拟化之三十 桌面虚拟化之安装View安全服务器
- 致逝去的时光