IFNULL(expr1,expr2)如果expr1不是NULL,IFNULL()返回expr1,否则它返回expr2。IFNULL()返回一个数字或字符串值具体用法如:现有学生表(tbl_student)和分数表(score),查询学生表的所有字段和学生相对于的英语成绩(eng ...
IFNULL(expr1,expr2)
如果expr1不是NULL,IFNULL()返回expr1,否则它返回expr2。IFNULL()返回一个数字或字符串值
具体用法如:现有学生表(tbl_student)和分数表(score),查询学生表的所有字段和学生相对于的英语成绩(english_score)sql如下:
select stu.*,IFNULL(score.english_score,0) from tbl_student stu,tbl_score score where 1=1 and stu.stu_id=score.stu_id
以上sql中,如果score表中的english_score有值,则IFNULL(score.english_score,0)就显示english_score,否则,显示0
原标题:mySql中IFNULL的使用说明
关键词:MYSQL
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。