SQL

Modifying Existing Data in MySQL

In this post, you will learn how to use the UPDATE feature in MySQL. The syntax of the UPDATE command will be shown in the code below. Using the information that was entered into an SQL table from this blog post, we can now update information at a specfic column. Let's say that we need to update the address for Elaine Huff. To do so we need to target her specifically and the best way to do this is to use their student_id in the case that there might be more than one Elaine Huff, which is student_id number 8. With the UPDATE command we have to name the table name, followed by SET which is used to update the value. The final command is WHERE, which will specify what row to update. To update, take a look at the code below.

SQL

                                
UPDATE students
SET address = '124 New Somewhere Lane, New SomeWhere, New State'
WHERE student_id = 8;
                                
                                Code copied
                            

In this blog post, we have learned how to update a table by using subqueries from the SET commands.