This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JDBC and the fly likes What is the difference between Distinct and Unique? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "What is the difference between Distinct and Unique? " Watch "What is the difference between Distinct and Unique? " New topic
Author

What is the difference between Distinct and Unique?

Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
What is the difference between Distinct and Unique?
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6657
    
    5

In what context ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5779
    
    7

And for which database?


JBoss In Action
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697
    
    5

If you are using it in projection to filter out duplicate results, then probably nothing. Some databases actually only support one of them (some support both), so this is more of a syntax issue than anything else.

Otherwise, UNIQUE can also be an attribute for a column making it a candidate/primary key, whereas DISTINCT is only used in SELECT statements.


My Blog: Down Home Country Coding with Scott Selikoff
 
jQuery in Action, 2nd edition
 
subject: What is the difference between Distinct and Unique?
 
Similar Threads
concurrent insertion
JRE vrs. JVM
Quick Question HttpSessionBinding vs HttpSessionAttribute Listeners
Differences
Run as AWT or SWT Application Eclipse Question