- The SELECT Statement
- Retrieving Individual Columns
- Retrieving Multiple Columns
- Retrieving All Columns
- Retrieving Distinct Rows
- Limiting Results
- Using Comments
- Summary
Retrieving Individual Columns
We’ll start with a simple SQL SELECT statement, as follows:
Input
SELECT prod_name FROM Products;
Analysis
The previous statement uses the SELECT statement to retrieve a single column called prod_name from the Products table. The desired column name is specified right after the SELECT keyword, and the FROM keyword specifies the name of the table from which to retrieve the data. The output from this statement is shown in the following:
Output
prod_name -------------------- Fish bean bag toy Bird bean bag toy Rabbit bean bag toy 8 inch teddy bear 12 inch teddy bear 18 inch teddy bear Raggedy Ann King doll Queen doll
A simple SELECT statement similar to the one used above returns all the rows in a table. Data is not filtered (so as to retrieve a subset of the results), nor is it sorted. We’ll discuss these topics in the next few lessons.