Database Reference
In-Depth Information
However, be aware that while the SQL language is not case sensitive, identifiers (the
names of databases, tables, and columns) might be. As a best practice, pick a case
convention, and use it consistently.
Tip
Use of White Space All extra white space within a SQL statement is ignored when that
statement is processed. SQL statements can be specified on one long line or broken up
over many lines. Most SQL developers find that breaking up statements over multiple
lines makes them easier to read and debug.
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.
Tip
Take Care with Commas When selecting multiple columns, be sure to specify a
comma between each column name, but not after the last column name. Doing so gen-
erates an error.
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 |