Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use != or <> for not equal in T-SQL?

I have seen SQL that uses both != and <> for not equal. What is the preferred syntax and why?

I like !=, because <> reminds me of Visual Basic.

like image 777
Bob The Janitor Avatar asked Apr 06 '09 20:04

Bob The Janitor


People also ask

Is it better to use <> or != In SQL?

If != and <> both are the same, which one should be used in SQL queries? Here is the answer – You can use either != or <> both in your queries as both technically same but I prefer to use <> as that is SQL-92 standard.

Is != Equivalent to <> in SQL?

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.

What is use of <> in SQL?

Compares two expressions (a comparison operator). When you compare nonnull expressions, the result is TRUE if the left operand is not equal to the right operand; otherwise, the result is FALSE.

Is not and != In SQL?

!= is a binary operator that returns true if its two arguments are not equal to each other. NOT is a unary operator, which reverses its argument, a Boolean expression.


1 Answers

Most databases support != (popular programming languages) and <> (ANSI).

Databases that support both != and <>:

  • MySQL 5.1: != and <>
  • PostgreSQL 8.3: != and <>
  • SQLite: != and <>
  • Oracle 10g: != and <>
  • Microsoft SQL Server 2000/2005/2008/2012/2016: != and <>
  • IBM Informix Dynamic Server 10: != and <>
  • InterBase/Firebird: != and <>
  • Apache Derby 10.6: != and <>
  • Sybase Adaptive Server Enterprise 11.0: != and <>
  • Mimer SQL 11.0: != and <>

Databases that support the ANSI standard operator, exclusively:

  • IBM DB2 UDB 9.5: <>
  • Microsoft Access 2010: <>
like image 186
9 revs, 5 users 71% Avatar answered Oct 06 '22 15:10

9 revs, 5 users 71%