字段中有空的时候 进行逻辑运算,mysql 与 oracle 处理函数IFNULL() 与 nvl() ,选取NULL 值 。

mySQL数据库:

SELECT id_p,IFNULL(math,0)+IFNULL(english,0) 总分 from mytest_brian1

Oracle 数据库:

select  id_p , nvl(address,0)* age from Persons2 ;       

NVL( string1, replace_with) 功能:如果string1为NULL,则NVL函数返回replace_with的值,否则返回string1的值。

NVL2(address, ,0 )  功能:   NVL2(E1, E2, E3)的功能为:如果E1为NULL,则函数返回E3,若E1不为null,则返回E2。

选取在 "Address" 列中带有 NULL 值的记录呢?

SELECT LastName,FirstName,Address FROM Persons WHERE Address IS NUL   

选取在 "Address" 列中不带有 NULL 值的记录呢? 

SELECT LastName,FirstName,Address FROM Persons WHERE Address IS NOT NULL

原文地址:https://www.cnblogs.com/brianlai/p/10300049.html