MYSQL UPDATE command:
-MySQL UPDATE statement is used to update data of the MySQL table within the database.
-In real life scenario, records are changed over the period of time. -So, we need to make changes in the values of the tables also.
-To do so, we need to use the UPDATE statement.
Syntax:
UPDATE table_name
SET column1=new-value1, column2=new-value2, ...
[WHERE condition]
SELECT * FROM library;
| Id |
Stud_name |
Book_id |
| 1 |
Aman |
234 |
| 2 |
Ram |
213 |
| 3 |
Ramesh |
89 |
| 4 |
John |
567 |
Now update some data:
UPDATE library SET Book_id=81 where Stud_name="Ramesh";
SELECT * FROM library;
| Id |
Stud_name |
Book_id |
| 1 |
Aman |
234 |
| 2 |
Ram |
213 |
| 3 |
Ramesh |
81 |
| 4 |
John |
567 |
-Here we change the Book_id of the Ramesh.