| Contents > Developing ColdFusion MX Applications > Introduction to Databases and SQL > Using SQL > Modifying a database Updating data in a database |
|
|
|
|
||
Use the UPDATE statement in SQL to update the values of a table row. Update lets you update the fields of a specific row or all rows in the table. The UPDATE statement has the following syntax:
UPDATEtable_name
SETcolumn_name1=value1, ... , column_nameN=valueN
[ WHEREsearch_condition]
Note: There are additional options to UPDATE depending on your database. For a complete syntax description for UPDATE, see the product documentation.
You should not attempt to update a record's primary key field. Your database typically enforces this restriction.
The UPDATE statement uses the optional WHERE clause, much like the SELECT statement, to determine which table rows to modify. The following UPDATE statement updates the e-mail address of John Smith:
UPDATE employees SET Email='jsmith@mycompany.com' WHERE EmpID = 51
Be careful using UPDATE. If you omit the WHERE clause to execute the following statement:
UPDATE employees SET Email = 'jsmith@mycompany.com'
you update the Email field for all rows in the table.
|
|
||
| Contents > Developing ColdFusion MX Applications > Introduction to Databases and SQL > Using SQL > Modifying a database Updating data in a database |
|
|
ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6.1
Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/sql24.htm