ASA SQL User's Guide
Queries: Selecting Data from a Table
The SELECT list: specifying columns
To SELECT only specific columns in a table, use this syntax:
SELECT column_name [, column_name ]...
FROM table-name
You must separate each column name from the column name that follows it with a comma. For example:
SELECT emp_lname, emp_fname FROM employee
The order in which you list the column names determines the order in which the columns are displayed. The two following examples show how to specify column order in a display. Both of them find and display the department names and identification numbers from all five of the rows in the department table, but in a different order.
SELECT dept_id, dept_name FROM department
dept_id | dept_name |
---|---|
100 | R & D |
200 | Sales |
300 | Finance |
400 | Marketing |
... | ... |
SELECT dept_name, dept_id FROM department
dept_name | dept_id |
---|---|
R & D | 100 |
Sales | 200 |
Finance | 300 |
Marketing | 400 |
... | ... |