emp set emp_id=100001 where emp_name=''红枫'';
修改结果显示如下:
+--------+----------+---------+---------+------------+---------+ | emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex | +--------+----------+---------+---------+------------+---------+ | 100005 | 啸天 | 27 | 3000 | 1979-07-10 | male | | 100001 | 红枫 | 29 | 8000 | 1977-01-01 | male | | 100002 | 丽鹃 | 27 | 7000 | 1979-12-31 | fmale | +--------+----------+---------+---------+------------+---------+ 3 rows in set (0.00 sec)
如果该语句没有后面的where限制,将会对表中所有的记录都进行修改。 如,给全部人加薪1000,可以如下修改: mysql> update emp set emp_sal=emp_sal+1000;
修改结果显示如下:
+--------+----------+---------+---------+------------+---------+ | emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex | +--------+----------+---------+---------+------------+---------+ | 100005 | 啸天 | 27 | 4000 | 1979-07-10 | male | | 100001 | 红枫 | 29 | 9000 | 1977-01-01 | male | | 100002 | 丽鹃 | 27 | 8000 | 1979-12-31 | fmale | +--------+----------+---------+---------+------------+---------+ 3 rows in set (0.00 sec)
----------------------我------------割--------------------------
2.6 高级查询方法
2.6.1 记录查询
查询emp表中,emp_ |