Database Reference
In-Depth Information
4
Retrieving Data
In this chapter, you learn how to use the SELECT statement to retrieve one or more
columns of data from a table.
The SELECT Statement
As explained in Chapter 1, “Understanding SQL,” SQL statements are made
up of plain English terms called keywords . Every SQL statement is made up
of one or more keywords. The SQL statement you'll probably use most fre-
quently is the SELECT statement. Its purpose is to retrieve information from
one or more tables.
To use SELECT to retrieve table data you must, at a minimum, specify two
pieces of information—what you want to select, and from where you want to
select it.
Retrieving Individual Columns
We start with a simple SQL SELECT statement, as follows:
Input
SELECT prod_name
FROM products;
Analysis
The previous statement uses the SELECT statement to retrieve a single column
called prod_name from the products table. The desired column name is
specified right after the SELECT keyword, and the FROM keyword specifies the
name of the table from which to retrieve the data. The output from this state-
ment is shown in the following:
 
 
 
 
Search WWH ::




Custom Search