The UPDATE Statement


The UPDATE Statement

The UPDATE statement updates data in one or more rows. UPDATE takes the name of the table to be updated, as well as the rows to be affected, and the new values.

The following example updates a single row in a table:

 UPDATE products SET product_price=49.99 WHERE product_id=235 

The WHERE clause restricts the rows being updated, and without it, all rows are updated. The following example increases the price of all products by 10:

 UPDATE products SET product_price=product_price+10 

To update multiple columns, you must separate each column=value pair with a comma.

CAUTION

Care must be taken to ensure that a WHERE clause is specified where needed (usually it will be). If you want to update a single row, the WHERE clause should always filter by the primary key.




Macromedia ColdFusion MX 7 Certified Developer Study Guide
Macromedia ColdFusion MX 7 Certified Developer Study Guide
ISBN: 0321330110
EAN: 2147483647
Year: 2004
Pages: 389
Authors: Ben Forta

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net