MySql IFNULL usage instructions, mysqlifnull

Source: Internet
Author: User

MySql IFNULL usage instructions, mysqlifnull

IFNULL (expr1, expr2)

If expr1 is not NULL, IFNULL () returns expr1; otherwise, it returns expr2. IFNULL () returns a number or string value

For example, the current student table (tbl_student) and score table (score) are used to query all the fields in the student table and the English score (engish_score) of the student table. The SQL statement is as follows:

Select stu. *, IFNULL (score. engish_score, 0) from tbl_student stu, tbl_score score where 1 = 1 and stu. stu_id = score. stu_id

In the preceding SQL statement, if the score table contains a value for engish_score, IFNULL (score. engish_score, 0) indicates engish_score. Otherwise, 0 is displayed.

Related Article

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.