可以使用 not like
LIKE 操作符用于在 WHERE 子句中搜索列中的指定模式
not like 即表示不包含某条件
例子:
Persons 表:
Id LastName FirstName Address City
1 Adams John Oxford Street London
2 Bush George Fifth Avenue New York
3 Carter Thomas Changan Street Beijing
选取居住在不包含 "lon" 的城市里的人
SELECT * FROM Persons WHERE City NOT LIKE '%lon%'
结果集:
Id LastName FirstName Address City
2 Bush George Fifth Avenue New York
3 Carter Thomas Changan Street Beijing
MYSQL不是SQLServer,MYSQL要使用LOCATE()或 INSTR()函数。
SELECT * FROM A WHERE LOCATE('[kid]',B)=0 and LOCATE('[/kid]',B)=0
--或者
SELECT * FROM A WHERE INSTR(B,'[kid]')=0 and INSTR(B,'[/kid]')=0
select * from A where B not like '%[[]KID[]]%' and B not like '%[[]/KID[]]%'
!=
not in
not like
<>
同上,可以用like
或者用函数,substring,charindex。。等等