in this tutorial, we will learn how to update data in MySQL. We will use where and SET clause to update data.


SQL syntax

UPDATE table_name SET field1 = new-value1, field2 = new-value2
[WHERE Clause]


My table:

MariaDB [testdb]> select * from post_table;
+----+------------------+-----------+------------+
| id | title            | auther    | post_date  |
+----+------------------+-----------+------------+
|  1 | MySQL Tutorial   | Rathorji  | 2021-02-10 |
|  2 | PHP Tutorial     | Rathorji  | 2021-02-10 |
|  3 | Laravel Tutorial | Rudranshi | 2021-02-10 |
+----+------------------+-----------+------------+


We want to update row 3 auther Rudranshi to Rathorji

UPDATE `post_table` SET `auther` = 'Rathorji' WHERE id = 3;


Updated table

MariaDB [testdb]> select * from post_table;
+----+------------------+----------+------------+
| id | title            | auther   | post_date  |
+----+------------------+----------+------------+
|  1 | MySQL Tutorial   | Rathorji | 2021-02-10 |
|  2 | PHP Tutorial     | Rathorji | 2021-02-10 |
|  3 | Laravel Tutorial | Rathorji | 2021-02-10 |
+----+------------------+----------+------------+


Thanks this will help you ..............





Are you facing problems in understanding this article?
You can watch the video. Watch it now