mysql中的 isnull(exper)、ifnull(exper1,exper2)、nullif(exper1,exper2)函数

1.isnull(exper) 判断exper是否为空,是则返回1,否则返回0

如expr 为null,那么isnull() 的返回值为 1,否则返回值为 0

tb_student_record表
mysql中的 isnull(exper)、ifnull(exper1,exper2)、nullif(exper1,exper2)函数- -> SELECT org_id,ISNULL(org_id) FROM tb_student_record
为 null 的返回值为1,否则返回值为0
mysql中的 isnull(exper)、ifnull(exper1,exper2)、nullif(exper1,exper2)函数

2.ifnull(exper1,exper2)判断exper1是否为空,是则用exper2代替

假如expr1 不为 NULL,则 IFNULL() 的返回值为 expr1;
否则其返回值为 expr2。IFNULL()的返回值是数字或是字符串,具体情况取决于其所使用的语境。
mysql中的 isnull(exper)、ifnull(exper1,exper2)、nullif(exper1,exper2)函数

3.nullif(exper1,exper2)如果expr1= expr2 成立,那么返回值为NULL,否则返回值为 expr1

如果expr1= expr2 成立,那么返回值为NULL,否则返回值为 expr1。这和CASE WHEN expr1 = expr2 THEN NULL ELSE expr1 END相同。
mysql中的 isnull(exper)、ifnull(exper1,exper2)、nullif(exper1,exper2)函数