![]() |
|
|
Deleting records in a database tableDownload the codeBelow is a table called 'Members_tbl' with 3 rows of data which belongs to a database called 'Members'. ![]() Using the SQL WHERE Clause we are going to delete the rows where the City column is equal to Belfast. This will delete two records in our example. Call our file 'deleting_records.asp'. <%@ Language="VBScript" %> We could add more criteria to the SQL statement. If we wanted to only delete the records where City was equal to Belfast and the FirstName was equal to Michael we could use the SQL statement below and assign to our variable sSQL. sSQL="DELETE * FROM Members_tbl WHERE CITY='BELFAST' AND FIRSTNAME='MICHAEL' " Just a note that SQL uses single quotes around text values . Numeric values should not be enclosed in quotes. If we wanted to delete the record where Id equals 3 we would write it as below without the enclosing ' and then assign to our variable sSQL. sSQL="DELETE * FROM Members_tbl WHERE Id=3" As a final note we haven't used the the recordset object as we are not returning a recordset, we are simply deleting records.
Site developed by Michael Wall - Web Design Belfast N.Ireland. |
|