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 ?
Difference between SQL Not Equal Operator <> and != to do inequality test between two expressions. Both operators give the same output. The only difference is that '<>' is in line with the ISO standard while '!= ' does not follow ISO standard.
There is no difference. According to SQL.org, the !=
Here is the answer – Technically there is no difference between != and <>. Both of them work the same way and there is absolutely no difference in terms of performance or result. Here is the follow up question I received right I answer that there is no difference between those operator.
not equal to (<>, !=) operator. MySQL Not equal is used to return a set of rows (from a table) after making sure that two expressions placed on either side of the NOT EQUAL TO (<>) operator are not equal. Syntax: <>, !=
<>
should be preferred, all things being equal, since it accords with the sql standard and is technically more portable...
!=
is non-standard, but most db's implement it.
sql:2008 grammar:
<not equals operator> ::= <>
They are both exactly the same. See the documentation.
http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_not-equal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With