数据库
首页 > 数据库> > mysql is 、is not 和 <=>

mysql is 、is not 和 <=>

作者:互联网

#案例:查询没有奖金的员工名和奖金率
#=或<>号不能判断是否等于null值,用is和is not判断

SELECT 
    last_name,
    commission_pct
FROM
    employees
WHERE
    commission_pct IS NULL;

#案例:查询有奖金

SELECT 
    last_name,
    commission_pct
FROM
    employees
WHERE
    commission_pct IS NOT NULL;

安全等于: <=>,也可以判断null值和普通类型的值

SELECT 
    last_name,
    commission_pct
FROM 
    employees
WHERE
    commission_pct <=> NULL;

标签:last,pct,commission,mysql,NULL,WHERE,SELECT
来源: https://blog.51cto.com/14437184/2435252