Share the actual procedure of modifying MySQL Data

Source: Internet
Author: User

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

 
 
  1. MySQL (best combination with PHP)> update emp set emp_id = 100001 where emp_name = 'hongfeng ';

The Modification result is as follows:

 
 
  1. + -------- + ---------- + --------- + ------------ + --------- +
  2. | Emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex |
  3. + -------- + ---------- + --------- + ------------ + --------- +
  4. | 100005 | Xiaotian | 27 | 3000 | 1979-07-10 | male |
  5. | 100001 | Hongfeng | 29 | 8000 | male |
  6. | 100002 | Lili | 27 | 7000 | 1979-12-31 | fmale |
  7. + -------- + ---------- + --------- + ------------ + --------- +
  8. 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:

 
 
  1. MySQL (best combination with PHP)> update emp set emp_salemp_sal = emp_sal + 1000;

The Modification result is as follows:

 
 
  1. + -------- + ---------- + --------- + ------------ + --------- +
  2. | Emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex |
  3. + -------- + ---------- + --------- + ------------ + --------- +
  4. | 100005 | Xiaotian | 27 | 4000 | 1979-07-10 | male |
  5. | 100001 | Hongfeng | 29 | 9000 | male |
  6. | 100002 | Lili | 27 | 8000 | 1979-12-31 | fmale |
  7. + -------- + ---------- + --------- + ------------ + --------- +

The above content is the description of MySQL data modification, hoping to help you in this regard.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.