24.4.6 UPDATE Statement

An UPDATE statement modifies data in a table. Its basic form is

UPDATE tableName   SET columnName1 = value1, columnName2 = value2, ..., columnNameN = valueN   WHERE criteria

where tableName is the table to update. The tableName is followed by keyword SET and a comma-separated list of columnName = value pairs. The optional WHERE clause provides criteria that determine which rows to update. Though not required, the WHERE clause is typically used, unless a change is to be made to every row. The UPDATE statement

UPDATE Authors   SET LastName = 'Black'   WHERE LastName = 'Red' AND FirstName = 'Sue'

updates a row in the Authors table. The statement indicates that ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.