条件语句:NOT 语句
MySQL的NOT条件与IN条件账号相反,用来在SQL语句中判断与表达式不匹配的项。
语法:
NOT condition
参数
condition: 要取反的条件。
MySQL NOT 与 IN 条件:
数据表officers
,如下所示:
执行查询语句:
SELECT *
FROM officers
WHERE officer_name NOT IN ('Ajeet','Vimal','Deepika');
输出:
MySQL NOT 与 IS NULL 条件:
执行查询语句:
SELECT *
FROM officers
WHERE officer_name IS NOT NULL;
输出:
MySQL NOT 与 LIKE 条件:
同样以数据表 officers
为例:
执行查询语句:
SELECT *
FROM officers
WHERE officer_name NOT LIKE 'A%';
输出:
MySQL NOT 与 BETWEEN 条件:
同样以数据表 officers
为例:
执行查询语句:
SELECT *
FROM officers
WHERE officer_id NOT BETWEEN 3 AND 5;
输出:
推荐文章: