是的,NOT EQUAL 在 Mysql 中存在于 运算符的形式中。语法如下 -SELECT * FROM yourTableName WHERE yourColumnName <> yourValue;为了理
是的,NOT EQUAL 在 Mysql 中存在于 运算符的形式中。语法如下 -
SELECT * FROM yourTableName WHERE yourColumnName <> yourValue;
为了理解上述语法,让我们创建一个表。创建表的查询如下 -
mysql> create table DoesNotEqualDemo
-> (
-> Id int NOT NULL AUTO_INCREMENT,
-> Name varchar(20),
-> PRIMARY KEY(Id)
-> );
Query OK, 0 rows affected (0.98 sec)
使用插入命令在表中插入一些记录。插入记录的查询如下 -
mysql> insert into DoesNotEqualDemo(Name) values(NULL);
Query OK, 1 row affected (0.24 sec)
mysql> insert into DoesNotEqualDemo(Name) values('John');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DoesNotEqualDemo(Name) values('Carol');
Query OK, 1 row affected (0.43 sec)
mysql> insert into DoesNotEqualDemo(Name) values('Bob');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DoesNotEqualDemo(Name) values('');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DoesNotEqualDemo(Name) values('Larry');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DoesNotEqualDemo(Name) values(NULL);
Query OK, 1 row affected (0.10 sec)
使用 select 语句显示表中的所有记录。查询如下 -
mysql> select *from DoesNotEqualDemo;
以下是输出 -
+----+-------+
| Id | Name |
+----+-------+
| 1 | NULL |
| 2 | John |
| 3 | Carol |
| 4 | Bob |
| 5 | |
| 6 | Larry |
| 7 | NULL |
+----+-------+
7 rows in set (0.00 sec)
这里是选择所有不等于 NULL 以及空字符串的记录的查询 -
mysql> select *from DoesNotEqualDemo where Name <> 'NULL' and Name <> '';
以下是输出 -
+----+-------+
| Id | Name |
+----+-------+
| 2 | John |
| 3 | Carol |
| 4 | Bob |
| 6 | Larry |
+----+-------+
4 rows in set (0.00 sec)
--结束END--
本文标题: MySQL 中不存在 NOT EQUAL 吗?
本文链接: https://lsjlt.com/news/436750.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0