Questions: mysql batch update

Source: Internet
Author: User
Continued question: I want to teach mysql batch update questions UPDATEtableSETsCASEidWHEN1THEN1WHEN3THEN2ENDWHEREidIN (1, 3) to update a field. if I update two or more fields at the same time, how can I write ------ solution ...... Updatetablesetfiel: how to update mysql in batches
UPDATE table
SET s = CASE id
WHEN 1 THEN '1'
WHEN 3 THEN '2'
END
WHERE id IN (1, 3)
Update a field and write it like this. how to update two or more fields at the same time?

------ Solution --------------------
The same ......

Update table set field_a = '', field_ B = '',......

The ''part of your code is replaced by the case when syntax.

If other fields still depend on a field, replace the same structure

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.