Nhibernate HQL Subselect queries

匿名 (未验证) 提交于 2019-12-03 01:18:02

问题:

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.

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?

thanks

回答1:

Yes, it's possible.

The query above can be written in HQL as:

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


回答2:

I've run into this issue myself. Took me a while to realise that hql does not support subqueries in the from clause.

See section 14.13 in the hql documentation here.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!