我有以下疑问

SELECT * FROM table
WHERE tester <> 'username';

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子句将返回testerusername不匹配且tester不为null的所有行.

如果要包含空值,请try :

where tester <> 'username' or tester is null

如果要查找不包含"username"作为子字符串的字符串,则可以使用like:

where tester not like '%username%'

Mysql相关问答推荐

Select 一对列存在最短日期的记录列

SQL按另一个表中的字段进入顺序对子查询进行排序

用于将重复行的唯一列值作为单独列获取的SQL查询

如果我有USER列,如何将SQL CREATE TABLE与PostgreSQL和MySQL一起使用?

版本升级到5.0.0后在QueryDSL中使用Enum时出错

可以优化这个带有重复WHERE子句的查询吗?

Mysql根据文本语言或行数将列拆分为多列

SQL: Select TEXT 字段的子字符串比整个值快

仅当其他行相等时才 Select 行值

如何在更新语句中使用多个子字符串函数?

MySQL:从 n 个关系表中 Select 所有具有 MAX() 值的行

根据使用 mysql 的第一个过滤结果添加更多表行

查询给出错误时的 mySQL Group_Concat 和 Case

在 MySQL 中使用三个表进行计算

添加一个日期字段大于另一个日期字段的要求

MySQL - 如何 Select 值在数组中的行?

如何使用 phpmyadmin 复制数据库?

将 Blob 转换为字节数组的最简单方法

在 MySQL 中签名或未签名

ON UPDATE RESTRICT 有什么作用?