![]() ![]() ![]() |
Deleting data in a database can be done with a single delete page. The delete page contains a CFQUERY tag with a SQL delete statement.
The syntax for a SQL delete statement is:
DELETE FROM tablename WHERE condition
The condition controls whether or not the delete statement deletes a single record, several records, or all records.
The following example demonstrates deleting a single employee from the Employees table.
DELETE FROM Employees WHERE Employee_ID = 1
The following example demonstrates deleting several records from the Employee table. The example assumes that there are several Employees in the sales department.
DELETE FROM Employees WHERE Department = 'Sales'
The following example demonstrates deleting all the records from the Employees table.
DELETE FROM Employees
Deleting records from a database is not reversible. Use delete statements carefully.
<!--- Page to delete single employee record ---> <CFQUERY NAME="DeleteEmployee" DATASOURCE="Employee DB"> DELETE FROM Employees WHERE Employee_ID = #URL.EmployeeID# </CFQUERY> <HTML> <HEAD> <TITLE>Delete Employee Record</TITLE> </HEAD> <BODY> <H3>The employee record has been deleted.</H3> </BODY> </HTML>
![]() ![]() ![]() |
AllaireDoc@allaire.com
Copyright © 1998, Allaire Corporation. All rights reserved.