开发者

JPA - getting distinct value from one column

开发者 https://www.devze.com 2023-01-13 12:26 出处:网络
I have an entity that has few fields. One of them is city name. Now I want to get list of all distinct cities from that tab开发者_JS百科le. How can I archive that. I tried using DISTINCT keyword, but

I have an entity that has few fields. One of them is city name. Now I want to get list of all distinct cities from that tab开发者_JS百科le. How can I archive that. I tried using DISTINCT keyword, but it doesn't work.

I'm using Hibernate as JPA provider but I would like to get it in pure JPA Query.


Have you tried:

SELECT DISTINCT t.city FROM MyTable t
0

精彩评论

暂无评论...
验证码 换一张
取 消