SQL:如何执行字符串不等于 [英] SQL: How to perform string does not equal

查看:666
本文介绍了SQL:如何执行字符串不等于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下查询

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆