3
如何使用JPA查詢語言執行以下操作?在JPA查詢中使用group by和having
select * from person where email in
(select email from person group by email having count(email)>1)
如何使用JPA查詢語言執行以下操作?在JPA查詢中使用group by和having
select * from person where email in
(select email from person group by email having count(email)>1)
終於找到了解決辦法:
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
從this link,有一個JPA SELECT查詢的一般結構的解釋:
SELECT ... FROM ...
[WHERE ...]
[GROUP BY ... [HAVING ...]]
[ORDER BY ...]