• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

DISTINCT in EJB-QL

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello:

I have a doubt about the clause DISTINCT, I dont understand what exactly does!!!.

What criteria does distinct uses to determine what object is repited?

Example

SELECT DISTINCT OBJECT(p)
FROM Player p

in this example what does distinct serch to determinate if one object is repeated? it searches all the fields??? except primary keys or what?javascript: x()

I expect that all opf you understand the question, if no, please show an example of distinct and exactly what things it does.

thanks a lot

carlos
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have a look at the EJB spec section 11.2.8 (SELECT clause), it states:


The DISTINCT keyword is used to specify that duplicate values must be eliminated from the query result.



In clear it means, that if the query you make against the DB ever returns duplicate values, only one of them will show up in the result set.
 
Carlos Llona
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Valentin! but

then, Distinc eliminates my entities repeated? if my query bring me for example the player with the primary key="00001" 5 times. with distinc I will only recive 1 record. is that right?

but!!!.

are there any different for example if I do this?:
SELECT DISTINCT OBJECT(p)
FROM Player p

or

SELECT OBJECT(p)
FROM Player p

In my database sample there are only 10 records. I suposse that the two queries always bring me 10 records. I dont imagine in what case (maybe using the clouse where) I could get a record repeated.

can you give me one sample plz

thanks a lot

Carlos
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic