Reputation: 431
whats the difference between !=
and <>
in mysql.
which symbol is good to user in sql query for not equal condition.can someone tell me whats the pros and cons of using the not equal symbol in mysql.
Upvotes: 35
Views: 32000
Reputation: 1
In some cases, when use mapper frameworks that use xml like mybatis (in java), is very necessary use != instead of <> ,probably you will get an error. Because if you use <> in xml(mybatis) probably need to close tag, and != it's right to use in this case.
like this (check where sql clause)
WHERE c.activate!=0Upvotes: 0
Reputation: 51565
!=
requires 3 keystrokes (Shift, !, =), and <>
requires 3 keystrokes (Shift, <, >). However a touch typist has to switch hands to hit that =
.
You should definitely use <>
over !=
. You'll save at least 10 milliseconds of typing for each use.
Upvotes: 87
Reputation: 2344
There is no difference. According to SQL.org, the != operator is converted to be <> by the compiler/interpreter during execution so in essence it is just an alias.
http://www.sql.org/sql-database/postgresql/manual/functions-comparison.html
Upvotes: 7
Reputation: 44386
There is absolutely no difference in MySQL, but the <>
is the variant present in the SQL ISO standard.
If you're interested in trivia I can tell you that Oracle also has ^=
apart from those two.
Upvotes: 31