Retrieving Multiple Columns
To retrieve multiple columns from a table, you use the same SELECT statement. The only difference is that you must specify multiple column names after the SELECT keyword, and separate each column 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 as follows:
Output
+---------+----------------+------------+ | prod_id | prod_name | prod_price | +---------+----------------+------------+ | ANV01 | .5 ton anvil | 5.99 | | ANV02 | 1 ton anvil | 9.99 | | ANV03 | 2 ton anvil | 14.99 | | OL1 | Oil can | 8.99 | | FU1 | Fuses | 3.42 | | SLING | Sling | 4.49 | | TNT1 | TNT (1 stick) | 2.5 | | TNT2 | TNT (5 sticks) | 10 | | FB | Bird seed | 10 | | FC | Carrots | 2.5 | | SAFE | Safe | 50 | | DTNTR | Detonator | 13 | | JP1000 | JetPack 1000 | 35 | | JP2000 | JetPack 2000 | 55 | +---------+----------------+------------+