|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Creating an Update Page with CFQUERY
|
|
|
|
For more complicated updates, you can use a SQL update statement in a CFQUERY tag instead of a CFUPDATE tag. The SQL update statement is more flexible for complicated updates.
|
|
|
|
Syntax |
|
|
|
The syntax for a SQL update statement is:
UPDATE tablename
SET columnname = value
WHERE condition
After the SET clause, a table column must be named. Then, you indicate a constant or expression as the value for the column.
|
|
|
|
Example: CFQUERY update page
|
|
|
To update the record with the front end form from the example above using a CFQUERY use this syntax:
<CFQUERY NAME="UpdateEmployee"
DATASOURCE="Employee DB">
UPDATE Employees
SET Firstname='#Form.Firstname#',
LastName='#Form.LastName#',
Phone='#Form.Phone#'
WHERE Employee_ID=#Employee_ID#
</CFQUERY>
|
|
|
|
Note
|
|
|
The WHERE statement is optional, but if you do not use it in the SQL UPDATE statement or the UPDATE command, then every row in the database will be updated.
|
|
|
  
|
|
|
AllaireDoc@allaire.com
Copyright © 1998, Allaire Corporation. All rights reserved.
|