MySQL Tutorial – MySQL UPDATE Command

MySQL Tutorial MySQL UPDATE Command

This lesson will teach us how to update our records in the database. The UPDATE command is used to update records in the table. Here is the general form of UPDATE command:

UPDATE table_name SET
column_name1 = value1,
column_name2 = value2,
column_name3 = value3 …
WHERE [conditions];

Note: The where clause in the update command specifies which records should be updated. If you exclude the where clause all records will be updated.

Let’s see some example of UPDATE command:

Here is our database table: (employee_record)

[TABLE=3]

We will update the salary of the employees that have a position of programmer. The salary will increase to 30000. Issue the command:

UPDATE employee_record SET
salary = 30000
WHERE position=”Programmer”;

Once you have encoded the command correctly, it will display a success message.

Ex. Query OK, 1 row affected (0.02 sec)
    Rows matched: 1 Changed: 1 Warnings: 0

Note: If we excluded the where clause it will update all the salary of the employee.

, , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.