简体   繁体   English

相当于!=的sql运算符

[英]sql operator equivalent to !=

I want to select all the fields where a certain column is not a value I specify. 我想选择某个列不是我指定的值的所有字段。

I tried this but it didn't work. 我试过了,但是没有用。

SELECT * 
FROM table 
WHERE columnname != value

My mistake. 我的错。

It was another error so I thought it was wrong with != operator cause it was the first time I use it. 这是另一个错误,所以我认为!=运算符是错误的,因为这是我第一次使用它。 Sorry guys! 对不起大家!

SELECT * 
FROM table 
WHERE columnname <> value

For MySQL: != or <> are correct. 对于MySQL: !=<>是正确的。

http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html

You should consider NULL columns also. 您还应该考虑NULL列。 You can do WHERE columnname IS NOT NULL also. 您也可以在WHERE columnname IS NOT NULL

In SQL, I believe inequality is 在SQL中,我相信不平等是

<>

though many implementations also allow 尽管许多实现也允许

!=

Either <> or != <>!=

From: MySQL Manual (version 5.0) 来自: MySQL手册 (5.0版)

<>, != <>,!=

Not equal: 不等于:

mysql> SELECT '.01' <> '0.01'; mysql> SELECT'.01'<>'0.01'; -> 1 mysql> SELECT .01 <> '0.01'; -> 1个mysql> SELECT .01 <>'0.01'; -> 0 mysql> SELECT 'zapp' <> 'zappp'; -> 0 mysql> SELECT'zapp'<>'zappp'; -> 1 -> 1

You need to post the query you are using, because != works fine for me in MySQL 4.1 您需要发布正在使用的查询,因为!=在MySQL 4.1中对我来说效果很好

As others mentioned, <> is equivalent. 正如其他人提到的, <>是等效的。 The != is ANSI standard (99 I believe). !=是ANSI标准(我相信是99)。

WHERE NOT columnname = value

NOT IN是一种味道, 这是一个tsql取反示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM