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.
3 Answers
!=
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.
-
5I do not agree. You have to perform the same actions for both (more or less):
Shift, !, release Shift, =
andShift, <, >, release Shift
. Also because for<>
you have to hold theShift
twice longer you will suffer more stress in your fingers. Also the buttons are closer to each other for<>
and that contributes as well to the stress in the articulations. TL;DR<>
is bad for your long term health. ISO should really take this into consideration and update the standard! Aug 12, 2011 at 13:04 -
5@Alin Purcaru: I wrote this answer with my tongue planted in my cheek, but I have to disagree. For a touch typist,
<>
is faster to type than!=
. Aug 12, 2011 at 13:16 -
2@Alin Purcaru: Yes, we're going way off topic. However, some questions deserve the satirical treatment. Aug 12, 2011 at 14:07
-
3But
!=
makes more sense. Simply read the letters out loud and you'll understand the meaningnot, equal
compared to readingless than, greater than
. Dec 11, 2012 at 3:18 -
3With an AZERTY keyboard != doesn't require the use of the shift key while <> does (but switching between QUERTY and AZERTY will result in a massive number of typing errors!) Feb 24, 2016 at 10:47
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.
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
-
You did see that that is the documentation for PostgreSQL, right? Aug 12, 2011 at 12:58
-
yes but is really based on the standard so most sql implementations will probably implement in similar manner. although to be absolutely sure i suppose I could dig into the code of the MYSQL since it is open source ish.– BuellerAug 12, 2011 at 13:00