문제

How would you do the following using the JPA query language?

select * from person where email in
(select email from person group by email having count(email)>1)
도움이 되었습니까?

해결책

Finally found a solution:

select p from Person p
where p.email in (
    select q.email
    from Person q
    group by q.email having count(q.email)>1)
order by p.email, p.id

다른 팁

From this link, there's a explanation of the general structure of a JPA SELECT Query:

SELECT ... FROM ...
[WHERE ...]
[GROUP BY ... [HAVING ...]]
[ORDER BY ...]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top