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  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
BRAINDUMP

Beginning SQL
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    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
     

       

    BRAINDUMP ARTICLES

    - Replacing Oracle with PostgreSQL
    - Demystifying SELinux on Kernel 2.6
    - Yahoo and Microsoft Create Ad Partnership
    - The Advantages of Obscure Open Source Browse...
    - Dell Announces CSI-style Digital Forensics S...
    - Milepost GCC Speeds Open-Source Development
    - Learn These 10 Programming Languages
    - Tomcat Capacity Planning
    - Internal and External Performance Tuning wit...
    - Tomcat Benchmark Procedure
    - Benchmarking Tomcat Performance
    - Tomcat Performance Tuning
    - Wubi: Windows-based Ubuntu Installer
    - Configuring and Optimizing Your I/O Scheduler
    - Linux I/O Schedulers





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek