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

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

问题描述

我有以下 SQL 查询:

I have the following SQL query:

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.

我的问题:是否可以在 from 子句中使用 HQL 进行子查询.如果没有,我可以先查询客户吗,有点像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天全站免登陆