Why are there two negation operators in SQL language? != and <>.
Are they redundant or is there a difference between them depending on operands ?
Which one should I use to negate strings in MySQL ?
Why are there two negation operators in SQL language? != and <>.
Are they redundant or is there a difference between them depending on operands ?
Which one should I use to negate strings in MySQL ?
<> is ISO Sql Standard!= is vendor specificThey both have no difference among them. It is just a personal preference which one to use. I always prefer <> since it is a ISO SQL standard
The SQL standard only specifies <> for not equals. SQL:2011 Foundation, section 5.2 <token> and <separator> specifies:
<not equals operator> ::= <>
However some SQL implementations (like MySQL) also support != as a lot of programmers are more familiar with != for not equals. They are fully equivalent, so you can use either, but from a standards point of view you should use <>.
See also the MySQL documentation for not equals.