How to update table values in batches

Source: Internet
Author: User
How to update table values in batches now I have a data table with the field type. There are N pieces of information in the data table. I want to change the type value based on different classid conditions. But now there are multiple types corresponding to multiple sets of conditions. for example, if class = 1, type = rassclass = 8, type = bbcc and multiple groups, how can I update table values in batches?
Now I have a data table with the field type. The data table contains N pieces of information,
I want to change the value of type based on different classid.
But now there are multiple types corresponding to multiple sets of conditions.
For example, when class = 1, type = rass
Class = 8, type = bbcc


There are multiple groups of such cases. how can I update all types one by one at a time.

I can't help myself. I just learned that I can think of the update table set type = corresponding value where class = corresponding value.

------ Solution --------------------
CASE value WHEN [compare_value] THEN result [WHEN [compare_value] THEN result...] [ELSE result] END
Case when [condition] THEN result [WHEN [condition] THEN result...] [ELSE result] END


Http://dev.mysql.com/doc/refman/5.1/en/control-flow-functions.html#operator_case

------ Solution --------------------
Your database does not conform to the third paradigm. we recommend that you break it down: Create (class, type) and remove the type from the original table.
------ Solution --------------------
SQL where queries that meet the conditions, and then updates
------ Solution --------------------
If the ing between your class and type is not regular, do not use if, else, or case when then. Otherwise, how long will it take?

Create a table separately and store the ing between class and type. when updating the table, run the following command with the table:

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.