gpt4 book ai didi

mysql - HQL : inner join

转载 作者:行者123 更新时间:2023-11-29 19:25:04 26 4
gpt4 key购买 nike

我想在 hql 查询中进行内部联接,但出现此错误:

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: ( ...

SELECT new myDto(
col1, col2
FROM table1,table2
INNER JOIN (
SELECT foo, bar, ... max(nb) as numberBar
FROM table1
GROUP BY foo, bar ...
) myAlias

ON table1.foo = myAlias.foo
AND table1.bar = myAlias.bar
...

查询在 sqldeveloper 中有效

最佳答案

只需检查您发布的查询,我认为您必须在 col2 之后关闭 new myDto 的括号,因为在您发布的查询中未关闭:

SELECT new myDto(
col1, col2)
FROM table1,table2
INNER JOIN (
SELECT foo, bar, ... max(nb) as numberBar
FROM table1
GROUP BY foo, bar ...
) myAlias

ON table1.foo = myAlias.foo
AND table1.bar = myAlias.bar
...

关于mysql - HQL : inner join,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42203916/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com