MySQL Tutorial

The UPDATE statement

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.

You might also like...

Comments

About the author

Gez Lemon United Kingdom

I'm available for contract work. Please visit Juicify for details.

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' but 'That's funny...'” - Isaac Asimov