Effect of null value in mysql on expression Calculation

Source: Internet
Author: User

The impact of null value in mysql during expression computation in mysql when any type of field and null value are calculated, the result is still null value www.2cto.com For example, 1 + null = null 'A' + null = null sometimes the null value must be automatically converted to an integer for expression calculation. use the CONVERT and CAST functions to forcibly CONVERT null to an integer type .. failed. finally, the if statement is used to solve this problem. For example, if (a is null, B, B + a) as c indicates that when field a is null, only calculate the value of field B and use the alias c. Otherwise, add the value of field B and field a to obtain the alias c a B null 1 1 1 select if (a is null, B, B + a) as c from table, the final result is c 1 2.

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.