The update case needs to be updated according to the condition column in MySQL update

Source: Internet
Author: User
Tags mysql update

Whether the following two statements can be combined into one:

UpdateT9SetId=1 whereB>'2015-10-12'; UpdateT9SetId=1E='2015-01-01'  whereB='2015-10-12';

Now that I've come to write a blog, the answer must be yes,

Here's how to combine the two update statements above into one:

 update  T9 set  id=  1 , E=  ( Span style= "color: #ff00ff;" >case  when  b=   '  2015-10-12   '   

That

When b equals '2015-10-12' , the E value is set to '2015-01-01' when B is greater than '  2015-10-12' , the E value remains the same.

This is a small trick, a friend who needs to take it though.

The update case needs to be updated according to the condition column in MySQL update

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.