ASA Getting Started
Selecting Data from Database Tables
You can limit the columns that a SELECT statement retrieves by listing the desired columns immediately after the SELECT keyword. This SELECT statement has the following syntax:
SELECT column-name-1, column-name-2,...
FROM table-name
where column-name-1, column-name-2, and table-name should be replaced with the names of the desired columns and table you are querying.
The list of result-set columns is called the select list. It is separated by commas. There is no comma after the last column in the list, or if there is only one column in the list. Limiting the columns in this way is sometimes called a projection.
List the name, description, and color of each product
In Interactive SQL, type the following in the SQL Statements pane and press F5 to execute the statement.
SELECT name, description, color FROM product
name | description | color |
---|---|---|
Tee Shirt | Tank Top | White |
Tee Shirt | V-neck | Orange |
Tee Shirt | Crew Neck | Black |
Baseball Cap | Cotton Cap | Black |
... | ... | ... |
The columns appear in the order in which you type them in the SELECT statement. If you want to rearrange the columns, simply change the order of the column names in the statement. For example, to put the description column on the left, use the following statement:
SELECT description, name, color FROM product