Update

<< Click to Display Table of Contents >>

Navigation:  Additional References > Database Primer >

Update

Previous pageReturn to chapter overviewNext page

 

The Update SQL statement allows existing data in database tables to be updated. The user will have to specify which records are to be affected and which table columns are to be updated. Based on our example, we now have an existing record with the following details: ID: 4. Lastname: Ford. Firstname: Debby. Address: 165 W Maple St. City: Los Angeles. Let's assume that the user realizes that a mistake has been made when the record was first created - i.e. the person’s first name should be spelled as 'Debbie' instead of 'Debby'. The user would now like to correct this mistake. The following SQL Update statement:

 

UPDATE Persons SET FIRSTNAME = 'Debbie' WHERE ID = 4

 

will then update the database record with the changes.