Source One Educational Society
   
Home | OS Install | MS-Office | Photoshop | SQL | Networking | HTML | Java | Model Papers | FAQ's | Health Tips | News | Jobs | Fun SMS
SQL Tutorial
SQL BASICS
o SQL INTRODUCTION
o SQL STATEMENTS
o SQL DISTINCT Statement
o SQL WHERE Clause
o SQL LIKE Condition
   
   
  Updated Soon...
 
 
SQL - (Structured Query Language)
   

 

The SELECT DISTINCT Statement

 

The DISTINCT keyword is used to return only distinct (different) values.

The SELECT statement returns information from table columns. But what if we only want to select distinct elements?

 

With SQL, all we need to do is to add a DISTINCT keyword to the SELECT statement:

 

Syntax

 
SELECT DISTINCT column_name(s)
FROM table_name
 

Using the DISTINCT keyword

 

To select ALL values from the column named "Company" we use a SELECT statement like this:

 
SELECT Company FROM Orders
 

"Orders" table

 
Company OrderNumber
Sheela 3412
365edu 2312
CIQ 4678
365edu 6798
 
Result
 
Company
Sheela
365edu
CIQ
365edu
 

Note that "W3Schools" is listed twice in the result-set.

 
SELECT DISTINCT Company FROM Orders
 

Result:

 
Company
Sheela
365edu
CIQ
 

Now "365edu" is listed only once in the result-set.

 
 
 
 
 
 
 
 
 
Home  |  Aboutus  |  Post Your Content  |  Terms of Service  |  Advertisement with us  |  Tell a Friend  |  Contact us  |  Sitemap
© 2009 365edu. All Rights Reserved. Site by 365edu. Best view in 1024x768 resolution.