Updating Data in a Table

0
10
Updating Data in a Table You can also change the existing data in a table with the UPDATE statement. As with the SELECT statement, you can add a WHERE clause to specify exactly which rows you want to update. If you leave out the WHERE clause, the entire table gets updated.

Here is an example to change values in your Course table using UPDATE statement

mysql > UPDATE Course SET Course name = ‘Java’, Duration = ‘10’ WHERE Course id = 3;

Query OK, 1 row affected
Rows matched: 1 Changed: 1 Warnings: 0

mysql > SELECT * from Course;

Output

Course id Course name Duration
1 C 3
2 ASP.NET 6
3 MySql 8

3 rows in set