- The SELECT Statement
- Retrieving Individual Columns
- Retrieving Multiple Columns
- Retrieving All Columns
- Retrieving Distinct Rows
- Limiting Results
- Using Comments
- Summary
- Challenges
Retrieving Individual Columns
We’ll start with a simple SQL SELECT statement, as follows:
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:
Depending on the DBMS and client you are using, you may also see a message telling you how many rows were retrieved and the processing time. For example, the MySQL command line would display something like this:
9 rows in set (0.01 sec)
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.