Adobe ColdFusion 8

Inserting into specific fields

The preceding example inserts data into all the fields of a table (the Employee table has seven fields). There might be times when you do not want users to add data into all fields. To insert data into specific fields, the SQL statement in the cfquery must specify the field names following both INSERT INTO and VALUES. For example, the following cfquery omits salary and start date information from the update. Database values for these fields are 0 and NULL, respectively, according to the database's design.

<cfquery name="AddEmployee" datasource="cfdocexamples">
    INSERT INTO Employee
        (Emp_ID,FirstName,LastName,
        Dept_ID,Contract)    
    VALUES 
        (#Form.Emp_ID#,'#Form.FirstName#','#Form.LastName#', 
        #Form.Dept_ID#,'#Form.Contract#')
</cfquery>