借助UPDATE语句和WHERE子句,我们可以更新表的单行或多行中的值。MySQL根据WHERE子句中指定的条件更新值。例如,假设在“ employee”表中,我们想要更改ID为1的雇员的“ name”和“ doj”,则可以使用以下查询完成-
mysql> UPDATE employee SET name = 'Gaurav', doj = '2010-02-01' WHERE id = 1; Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from employee WHERE id = 1; +------+--------+------------+ | id | name | doj | +------+--------+------------+ | 1 | Gaurav | 2010-02-01 | +------+--------+------------+ 1 row in set (0.00 sec)