Migol
Migol

Reputation: 8448

JPA - getting distinct value from one column

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 table. 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.

Upvotes: 3

Views: 3435

Answers (1)

mtpettyp
mtpettyp

Reputation: 5569

Have you tried:

SELECT DISTINCT t.city FROM MyTable t

Upvotes: 2

Related Questions