This article describes how to modify data in MySQL. This article describes how to modify data in MySQL by using actual code, the following is a detailed description of the article. I hope you will gain some benefits after browsing it.
Modify data in MySQL
Use the UPDATE statement to UPDATE table data
- MySQL (best combination with PHP)> update emp set emp_id = 100001 where emp_name = 'hongfeng ';
The Modification result is as follows:
- + -------- + ---------- + --------- + ------------ + --------- +
- | Emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex |
- + -------- + ---------- + --------- + ------------ + --------- +
- | 100005 | Xiaotian | 27 | 3000 | 1979-07-10 | male |
- | 100001 | Hongfeng | 29 | 8000 | male |
- | 100002 | Lili | 27 | 7000 | 1979-12-31 | fmale |
- + -------- + ---------- + --------- + ------------ + --------- +
- 3 rows in set (0.00 sec)
If this statement does not have the following where restriction, all the records in the table will be modified. For example, if you increase the salary by 1000 for all users, you can modify the salary as follows:
- MySQL (best combination with PHP)> update emp set emp_salemp_sal = emp_sal + 1000;
The Modification result is as follows:
- + -------- + ---------- + --------- + ------------ + --------- +
- | Emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex |
- + -------- + ---------- + --------- + ------------ + --------- +
- | 100005 | Xiaotian | 27 | 4000 | 1979-07-10 | male |
- | 100001 | Hongfeng | 29 | 9000 | male |
- | 100002 | Lili | 27 | 8000 | 1979-12-31 | fmale |
- + -------- + ---------- + --------- + ------------ + --------- +
The above content is the description of MySQL data modification, hoping to help you in this regard.