![]() ![]() ![]() |
For more complex inserts from a form submittal you can use a SQL INSERT statement in a CFQUERY tag instead of a CFINSERT tag. The SQL INSERT statement is more flexible because you can insert information selectively or use functions within the statement.
The syntax for a basic SQL insert statement is:
INSERT INTO tablename (columnnames) VALUES (values)
The VALUES keyword specifies the values for the columns in the new row. You have to type the values you want to add in the same order as the columns in the columnnames section of the statement.
To insert the form data from the example above with a CFQUERY use this syntax:
<CFQUERY NAME="AddEmployee" DATASOURCE="Employee DB"> INSERT INTO Employees (FirstName, LastName, Phone) VALUES ('#Form.FirstName#', '#Form.LastName#', '#Form.Phone#') </CFQUERY>
![]() ![]() ![]() |
AllaireDoc@allaire.com
Copyright © 1998, Allaire Corporation. All rights reserved.