Database Reference
In-Depth Information
Figure 4-4.
SELECT statement showing all the inserted rows with autogenerated ID value
Updating Data
You can modify data with the
UPDATE
statement. When coding
UPDATE
statements, you must be careful to
include a
WHERE
clause, or you'll update
all
the rows in a table. So, always code an appropriate
WHERE
clause; if you miss a
WHERE
clause, as shown in the following
UPDATE
statement, then you will change all
the records of the table, and I am sure no business case requires that!
UPDATE <table>
SET <columnl> = <valuel>, <column2> = <value2>, ..., <columnN> = <valueN>
Now that you're aware of the implications of the
UPDATE
statement, let's take a good look at it. In
essence, it's a simple statement that allows you to update values in one or more rows and columns.
UPDATE <table>
SET <columnl> = <valuel>, <column2> = <value2>, ..., <columnN> = <valueN>
WHERE <predicate>