Database Reference
In-Depth Information
EXAMPLE 28
Change the street address of customer 524 to 1445 Rivard.
104
You can use the SQL UPDATE command to make changes to existing data. After the word UPDATE, you
indicate the table to be updated. After the word SET, you indicate the field to be changed, followed by an
equals sign and the new value. Finally, you can include a condition in the WHERE clause in which case only
the records that satisfy the condition will be changed. The SQL command for this example appears in
Figure 3-57. When you run this query in Access, a dialog box opens and indicates the number of records the
UPDATE command will affect. In this case, you would update only one record because the WHERE clause
selects customer 524.
Table to be
updated
Change to
be made
Condition to select
customer 524
FIGURE 3-57
SQL query to update data
EXAMPLE 29
Add a new sales rep to the Rep table. Her number is 16; her name is Sharon Rands; and her address is 826
Raymond, Altonville, FL 32543. She has not yet earned any commission, but her commission rate is 5% (0.05).
To add new data to a table, you use the INSERT command. After the words INSERT INTO, you list the
name of the table, followed by the word VALUES. Then you list the values in parentheses for each of the col-
umns, as shown in Figure 3-58. Character values must be enclosed within single quotation marks. When you
run this query in Access, a dialog box opens and indicates the number of records the INSERT command will
append to the table. In this case, you would add one record to the Rep table.
Table into which to
insert th e new row
Values for the
new row
FIGURE 3-58
SQL query to insert a row
Search WWH ::




Custom Search