In MySQL, when a field is null, the function that converts to the value you want

IFNULL(expr1,expr2)

Among them, expr1 is the field in the table , expr2 is the value you want to convert when expr1 is null , and expr2 can be a number or a string, etc.

For example, the column1 field in the table table1 returns the number 0 at that time: IFNULL(column1, 0) ;

For example, the column2 field in the table table2 returns the string abc at that time: IFNULL(column2, 'abc') ;

Guess you like

Origin blog.csdn.net/dd2016124/article/details/128789433