Home arrow BrainDump arrow Page 3 - Beginning SQL

The Distinct Statement - BrainDump

It's great to have information organized in a database, but what do you do with it once it's in there? The answer is that you have to get it out again before you can do anything with it. And that's where Structured Query Language (SQL) comes in. Keep reading to learn more.

TABLE OF CONTENTS:
  1. Beginning SQL
  2. Retrieving Data from a Database
  3. The Distinct Statement
  4. Placing Data into a Database with SQL
By: James Payne
Rating: starstarstarstarstar / 14
September 25, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

BRAINDUMP ARTICLES

- Apple Founder Steve Jobs Dies
- Steve Jobs` Era at Apple Ends
- Google's Chrome Developer Tool Updated
- Google's Chrome 6 Browser Brings Speed to th...
- New Open Source Update Fedora 13 is Released...
- Install Linux with Knoppix
- iPad Developers Flock To SDK 3.2
- Managing a Linux Wireless Access Point
- Maintaining a Linux Wireless Access Point
- Securing a Linux Wireless Access Point
- Configuring a Linux Wireless Access Point
- Building a Linux Wireless Access Point
- Migrating Oracle to PostgreSQL with Enterpri...
- Demystifying SELinux on Kernel 2.6
- Yahoo and Microsoft Create Ad Partnership

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: