In this tutorial, you will learn, how to update the database table’s record using the mysql update query. Use the below syntax to write the update query:
1 2 | UPDATE table_name SET field1 = new-value1, field2 = new-value2 [WHERE Clause] |
Example based on above update query syntax:
1 2 3 | UPDATE employee SET emp_name = 'Ramesh Singh' WHERE emp_id = 12; |
Above query will update the employee name from the old name to new name as “Ramesh Singh” based on emp_id. After that execute the below mysql query to see the updated records from employee table.
1 | SELECT * FROM employee; |
After executing the above select query, you will see the updated records.