Ask how to bulk Update table values

Source: Internet
Author: User
How do I bulk Update table values
Now I have a data table with a field that is type. There are n information in the data table,
I want to change the value of type, as the condition is changed according to different ClassID.
But now there are multiple sets of type values corresponding to the set of conditions
For example, when Class=1, Type=rass
Class=8, TYPE=BBCC


There are a number of such cases, how to do a one-time one by one corresponding update all the type.

I have no way, just learned, I can think of IS Update table set type= corresponding value where class= corresponding value

------Solution--------------------
Case value when [compare_value] and then result [when [compare_value] then result ...] [ELSE result] END
case is [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, it is recommended to decompose: new (Class,type), remove the type from the original table.
------Solution--------------------
The where query in SQL matches the criteria, and then updates the
------Solution--------------------
If your class and type correspond to a pattern, don't write it with if,else or case and then how long do you have to write it?

You create a separate table, save the class and type correspondence, and Xia lian the table when you update 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.