MySQL 中 <> 和 != 运算符有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14159569/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between <> and != operators in MySQL?
提问by Alain Tiemblo
Possible Duplicate:
Should I use != or <> for not equal in TSQL?
If I use a simple table such as :
如果我使用一个简单的表格,例如:
create table test ( a int );
insert into test values ( 1 ) , ( 2 ) , ( 2 ) , ( 3 );
select * from test where a <> 2;
select * from test where a != 2;
Both give me :
两者都给我:
+------+
| a |
+------+
| 1 |
| 3 |
+------+
2 rows in set (0.00 sec)
So what is the difference between <>
and !=
mysql operators ?
那么<>
和!=
mysql操作符有什么区别呢?
采纳答案by anothershrubery
They are both exactly the same. See the documentation.
它们完全相同。请参阅文档。
http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_not-equal
http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_not-equal
回答by echo_Me
<>
should be preferred, all things being equal, since it accords with the sql standard and is technically more portable...
<>
应该是首选,所有事情都是平等的,因为它符合 sql 标准并且在技术上更易于移植......
!=
is non-standard, but most db's implement it.
!=
是非标准的,但大多数数据库都实现了它。
sql:2008 grammar:
sql:2008 语法:
<not equals operator> ::=
<>
回答by Hamlet Hakobyan
No difference. <>
is sql standard, !=
non-standard.
没有不同。<>
是sql标准的,!=
非标准的。
回答by Kevin
Nothing. Simply two different ways of writing the same thing
没有。只是写同一件事的两种不同方式