NOT LIKE
语法说明
NOT LIKE 操作符用于在 WHERE 从句中搜索列中的指定模式,是 LIKE 的否定用法。
有两个通配符经常与 LIKE 操作符一起使用:
- 百分号 (%) 代表了 0、1 或多个字符。
- 下划线 (_) 代表单个字符。
语法结构
1. > SELECT column1, column2, ...
2. FROM table_name
3. WHERE columnN NOT LIKE pattern;
示例
1. create table t1 (a char(10));
2. insert into t1 values('abcdef');
3. insert into t1 values('_bcdef');
4. insert into t1 values('a_cdef');
5. insert into t1 values('ab_def');
6. insert into t1 values('abc_ef');
7. insert into t1 values('abcd_f');
8. insert into t1 values('abcde_');
10. mysql> select * from t1 where a not like 'a%';
11. +--------+
12. | a |
13. +--------+
14. | _bcdef |
15. +--------+
16. mysql> select * from t1 where a not like "%d_\_";
17. +--------+
18. | a |
19. +--------+
20. | abc_ef |
21. +--------+
22. 1 row in set (0.01 sec)
