Java Reference
In-Depth Information
then only the four columns from each row would be returned as in the following:
111 Mary Worker 17.5 3
222 Joe Programmer 17.5 2
To retrieve only some rows, use the
where
keyword with a condition. A condition is comprised of two values and
a comparison operation (=, >, <, >=, <=, etc.). The values can be a static value or the name of a table field. For instance,
both of the following statements:
SELECT empnum, empname, payrate, exempts
FROM tntdb.employee
WHERE state = “OK”
SELECT empnum, empname, payrate, exempts
FROM tntdb.employee
WHERE exempts >= 3
return the following data:
111 Mary Worker 17.5 3
The first statement used the state field and a character string as part of the
where
condition. Notice that string
(character) values must be enclosed in quotes (as in the first statement), but numeric values are not (as shown in the
second statement's
where
condition).
SQL also provides data manipulation commands that allow users to modify data in a table, and the
where
keyword can be used with these statements to identify the particular rows to be manipulated.
Data Manipulation
Data manipulation is where SQL really shines. A single SQL
update
statement can modify many columns in many
rows. The
update
statement syntax is the
update
keyword followed by:
The schema and table names
The
set
keyword
For each column to be changed the following three items must be included:
The column name to be modified
An equal sign
The column's new value
then:
The
where
keyword
A condition that identifies the row(s) to be modified