本文主要是介绍(转)mysql 里面的isnull()和ifnull() is null 和 is not null,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
【转载原因:清晰明了】
【转载原文:https://blog.csdn.net/silentwolfyh/article/details/51966267?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task】
create table userinfo (num int not NULL,name varchar(20), age int , primary key(num));INSERT INTO userinfo(num , name , age) VALUES (1 , 'yuhui' , 30);
INSERT INTO userinfo(num , name , age) VALUES (2 , '余辉' , 30);
INSERT INTO userinfo(num , name , age) VALUES (3 , NULL , 31);
INSERT INTO userinfo(num , name , age) VALUES (4 , '雷杰旭' , 28);
INSERT INTO userinfo(num , name , age) VALUES (5 , '李辉' , 35);
INSERT INTO userinfo(num , name , age) VALUES (6 , '李岳铸' , 35);
INSERT INTO userinfo(num , name , age) VALUES (7 , '潘玉芳' , 18);
INSERT INTO userinfo(num , name , age) VALUES (8 , NULL, 30);
1.userinfo 表
SELECT * from userinfo;
2.找到里面userinfo 是null的行
SELECT * from userinfo where ISNULL(name) ORDER BY num
SELECT * from userinfo where name is NULL ORDER BY num
3.找到里面userinfo 不是null的行
SELECT * from userinfo where name is not NULL ORDER BY num
4.列出所有的行,并且将userinfo 是null的字段替换为hehe
SELECT num , IFNULL(name,"hehe") AS name ,age from userinfo ORDER BY num
————————————————
版权声明:本文为CSDN博主「北京小辉」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/silentwolfyh/article/details/51966267
这篇关于(转)mysql 里面的isnull()和ifnull() is null 和 is not null的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!