- The SELECT Statement
- Retrieving Individual Columns
- Retrieving Multiple Columns
- Retrieving All Columns
- Retrieving Distinct Rows
- Limiting Results
- Using Comments
- Summary
Retrieving Multiple Columns
To retrieve multiple columns from a table, the same SELECT statement is used. The only difference is that multiple column names must be specified after the SELECT keyword, and each column must be separated by a comma.
The following SELECT statement retrieves three columns from the products table:
Input
SELECT prod_id, prod_name, prod_price FROM Products;
Analysis
Just as in the prior example, this statement uses the SELECT statement to retrieve data from the Products table. In this example, three column names are specified, each separated by a comma. The output from this statement is shown below:
Output
prod_id prod_name prod_price --------- -------------------- ---------- BNBG01 Fish bean bag toy 3.4900 BNBG02 Bird bean bag toy 3.4900 BNBG03 Rabbit bean bag toy 3.4900 BR01 8 inch teddy bear 5.9900 BR02 12 inch teddy bear 8.9900 BR03 18 inch teddy bear 11.9900 RGAN01 Raggedy Ann 4.9900 RYL01 King doll 9.4900 RYL02 Queen dool 9.4900