The update statement is used to update records in a database. The keywords used in an update statement are summarised in the following table.
Keyword | Description |
---|---|
UPDATE | Updates data in one or more tables. |
SET | Specifies the field names to be updates. If the fields belong to more that one table, the table name should be specified before the field name. (eg. search.Page). |
WHERE | Criteria to restrict the records updated. |
The following example updates all records in the search table to change the category from Jive, to Java.
update.sql
UPDATE search
SET Category = 'Java'
WHERE Category = 'Jive';
The file may then be used with MySQL as follows:
mysql> \. update.sql
The same characters need escaping as mentioned on the previous page.
Comments