Which of the two (semantically equivalent) ways is preferable to test for inequality?
'foo' != 'bar'
(exclamation mark and equals sign)
'foo' <> 'bar'
(less than and greater than chevron symbols together)
The MySQL documentation clearly indicates that there is no difference between them and yet some people seem to be attached to only doing it one way or the other. Maybe this is just another pointless vi vs. emacs debate but when other people are reading your code (and therefore your queries), it's useful to maintain some consistency.
<>
looks a lot like <=>
which is a very underused operator but could perhaps lead to confusion at a quick glance since the two are nearly opposite (except for the obvious NULL
cases).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…