Nhibernate HQL子选择查询 [英] Nhibernate HQL Subselect queries

查看:61
本文介绍了Nhibernate HQL子选择查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下SQL查询:

select c.id
from (select id from customers) c

此查询没有实际价值-出于本文的目的,我对其进行了大大简化.

This query has no practical value - I simplified it greatly for the purpose of this post.

我的问题:使用HQL在from子句中是否可能有一个子查询.如果不是,我是否可以先查询客户(有点像sql中的临时表),然后将结果用作下一个查询的来源?

My question: is it possible have a subquery in the from clause using HQL. If not, can I perhaps query the customers first, kinda like a temp table in sql, and then use the result as the source of the next query?

谢谢

推荐答案

是的,有可能.

上面的查询可以用HQL编写为:

The query above can be written in HQL as:

select Id
from Customer
where Id in (select Id from Customer)

这篇关于Nhibernate HQL子选择查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆