8.3. The UPDATE Statement

The function of the UPDATE statement in SQL is to change the values in zero or more columns of zero or more of rows of one table. SQL implementations will tell you how many rows were affected by an update operation or, at a minimum, return the SQLSTATE value for zero rows affected. There are two forms of UPDATE statements: positioned and searched. The positioned UPDATE is done with cursors; the searched UPDATE uses a WHERE that resembles the search condition in a SELECT statement.

Positioned UPDATEs will not be mentioned in this book, for several reasons. Cursors are used in a host programming language, and we are concerned with pure SQL whenever possible. Secondly, cursors in SQL are different from cursors in SQL-89 ...

Get Joe Celko's SQL for Smarties, 3rd 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.