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.
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.