SQL:如何执行字符串不等于 [英] SQL: How to perform string does not equal
问题描述
我有以下查询
SELECT * FROM table
WHERE tester <> 'username';
我期望它返回测试器不是字符串username
的所有结果,但是这不起作用.我想我正在寻找Like
运算符的反函数,但不确定吗?在搜索中,我找到了数字的解决方案(那是我从那里得到<>的地方),但这似乎不适用于字符串.
I am expecting this to return all the results where tester is not the string username
, But this not working. I think I am looking for the inverse of the Like
operator but I am not sure? In my searches I have found solutions for numbers (that's where i got <> from), but this seems to not be working with strings.
推荐答案
您的where
子句将返回tester
不匹配username
并且tester
不为空的所有行.
Your where
clause will return all rows where tester
does not match username
AND where tester
is not null.
如果要包含NULL,请尝试:
If you want to include NULLs, try:
where tester <> 'username' or tester is null
如果要查找不包含单词"username"作为子字符串的字符串,则可以使用like
:
If you are looking for strings that do not contain the word "username" as a substring, then like
can be used:
where tester not like '%username%'
这篇关于SQL:如何执行字符串不等于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!