UPDATE…SET

This construct allows you to update the contents of a field. If you wish to change the contents of one or more fields, you need to first narrow in on just the field or fields to be changed, in much the same way you use the SELECT command.

Example:
UPDATE classics SET author=’Markku Aro (Markku Puputti)’
WHERE author=’Markku Aro’;
UPDATE classics SET type=’Suomi POP’
WHERE type=’POP’;

In the first query, Markku Aros’s real name of Markku Puputti was appended to his pen name in parentheses, which affected only one row. The second query, however, affected three rows, because it changed all occurrences of the word POP in the category column to the term Suomi POP. When performing an update, you can also make use of the qualifiers you have already seen, such as LIMIT, and the following ORDER BY and GROUP BY keywords.

Leave a Reply

Your email address will not be published. Required fields are marked *