SunQuest
 
       BrainDump
  Home arrow BrainDump arrow Page 3 - Beginning SQL
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

Beginning SQL
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 12
    2007-09-25

    Table of Contents:
  • Beginning SQL
  • Retrieving Data from a Database
  • The Distinct Statement
  • Placing Data into a Database with SQL

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Beginning SQL - The Distinct Statement


    (Page 3 of 4 )

    Let's say now that Homer Sampson has a twin brother. And let's further say that Homer Sampson's parents wanted to add to the confusion, and, much like the great boxer George Foreman, decided to give all their children the same exact name (perhaps they too, had been hit in the head one too many times). Go ahead, add him to your table, with the position of CFO and the same salary as his brother.

    If you were to print a last of first and last names, and their respective positions, it would look like this:

    Select FirstName, LastName, Position from Employees;

    First Name

    Last Name

    Position

    Larry

    Smith

    President

    Homer

    Sampson

    CEO

    Homer

    Sampson

    CFO

    Your

    Name

    Whipping Boy

    As you can see, there are two Homer Sampsons, with different positions within the company. Now say that you wanted to print just a list of first names, without having duplicates. For this you would need the Distinct statement.

    Select DISTINCT FirstName from Employees;

    This will give us a result that shows only first names that are different from one another.

    First Name

    Larry

    Homer

    You

    As you can see, there is now only one Homer listed.

    More BrainDump Articles
    More By James Payne


       · SQL is probably one of my favorite computer subjects to write about and the one I...
       · We offer a suggestion for clarification of using the delete function:The current...
     

       

    BRAINDUMP ARTICLES

    - More Amazing Things to Do With Pipelines
    - Pipelines Can Do Amazing Things
    - Better Command Execution with bash
    - Executing Commands with bash
    - Outsourcing: the Hoopla, the Reality
    - MySQL Plays in the Sun
    - All About SQL Functions
    - SQL: Functioning in the Real World
    - More Advanced SQL Statements
    - Beginning SQL the SEQUEL: Working with Advan...
    - Beginning SQL
    - A Look at the VI Editor
    - A Quick Tour of Boo
    - Book Review: Open Source Licensing
    - PGP and GPG: Email for the Practical Parano...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway