MySQL modifies 2 table ideas at the same time

Source: Internet
Author: User

1. Requirements: Change the nickname in the review form to the last 4 digits of the mobile phone number.

UPDATE SET = MID (Issuer_name,4,6WHERE=One and like' 1% ';

2. Due to Misoperation (mid (issuer_name,4,6) is the middle 6 bits), data rollback is required.

3. Establish the intermediate table (and 1<>1 conditions do not meet the establishment of empty table)

 create  table   TMP  select  T2. Reg_no,t2. Mobile,t1. ' Issuer_name ' from  trans_eval t1,member T2 where  t1.issuer_no t2. ' Reg_no '  4 , 6 ) =  t1. ' Issuer_name ' and  1  <>  1  group  by  T2. Reg_no,t2. Mobile,t1. ' Issuer_name '; 

4. Import data into the intermediate table

INSERT  into  SELECT T2. Reg_no,t2. Mobile,t1. ' Issuer_name ' from   trans_eval  WHERE=t2. ' Reg_no '     and  MID (T2 ' Mobile ',4,6=t1. ' Issuer_name '  GROUP by T2. Reg_no,t2. Mobile,t1. ' Issuer_name ';

5. Data recovery

SELECT *  from tmp; UPDATE SET T2. ' Issuer_name '=WHERE t1. ' reg_no '=T2. ' Issuer_no ';

MySQL modifies 2 table ideas at the same time

Related Article

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.