Database Basics
3-c: Database FAQsSo, what's the deal with the semicolon? The semicolon at the end of a statement simply tells the DBMS that you are done with that statement and it should process it now. DBMSs can very greatly when it comes to designating the end of a statement so be sure to check your DBMS and see which one is right for you. |
|
4-a: What is a SELECT statement?So, what does SELECT do? Very simply, it tells the DBMS that you want to get some data out of the database. So, how does it work? SELECT can range from very simple to painfully complex. With SELECT there are a whole host of different options available to you that will allow you specify, calculate and arrange your data in an infinite number of ways. |
|
4-b: What is a FROM clause?As you might have guessed, the FROM clause tells the DBMS what table to look in. Using our table we created in Part 2, our SELECT statement should look something like this now: |
|
4-c: What is a WHERE clause?A WHERE clause allows you to filter out any unwanted data so that the data you do get is exactly what you are looking for. Let's look for all of the people named "Paul" in our table. |
|
5-a: Some more about WHEREWhat if you have a much more complex set of criteria that you would like to apply to filter? Well, you're in luck. SQL gives you quite a lot of flexibility in defining how you filter your data. |
|
5-b: What about Sorting?What if I want to sort my data? Do I have to write some customized sorting script to sort the data after I get it out? Thankfully, no. SQL has already done that work for you. Here's an example of how you would retrieve and sort all of the last names in our "contacts" table that we created way back in Parts 1 and 2: |
|
5-c: What about Grouping?Imagine this scenario, you are running a gift catalog business for corporations and you want to know how many items have been sold to each corporate client you have. To accomplish this task you will need to learn about COUNT and GROUP BY. |
|
6-a: What Are Aggregate Functions?Wouldn't it be great if SQL provided you with some basic functions for averaging, counting or finding the largest or smallest number in a set of numbers? Well, I'm sure you've guessed that aggregate functions do exactly that. |
|

