What is the exact Difference between <> and != ?
-
I don't think there is, but you might want to be more specific about the sql dialect ... ANSI SQL (year?), Oracle, MS T-SQL, DB2, MySql, ...? – Vik David May 02 '11 at 11:24
-
6Related: http://stackoverflow.com/questions/723195/should-i-use-or-for-not-equal-in-tsql/723426#723426 – Joachim Sauer May 02 '11 at 11:25
-
Why this question should be close? – Vijjendra May 02 '11 at 11:28
-
Well, the reason given for closing it is "not a real question". I don't see what justification there is for that, as it seems a pretty straight-forward question. If it's closed for that reason, I for one will be voting to re-open. – Jon Hanna May 02 '11 at 22:10
6 Answers
None whatsoever, syntactically.
Both are inequality operators, <>
is the SQL-92 standard, however its interchangable on some platforms with !=
(E.g. SQL Server)

- 171,639
- 30
- 264
- 288
<>
is the only inequality operator in the SQL Standard.
Lot's of SQL database systems support the use of !=
including PostgreSQL, SQL Server, MySQL, SQLite, Oracle & Firebird, but some don't, including Apache Derby.

- 110,372
- 10
- 146
- 251
In Oracle there is no difference. Can't speak for all other databases.

- 3,525
- 5
- 28
- 46
-
7@Vijjendra: When you say "SQL" it may be that you mean "Microsoft SQL Server", but to many of us "SQL" is a query language supported by many database products, among them Oracle, PostgreSQL, MySQL, Firebird, Rdb, Microsoft Access, and many others. – Bob Jarvis - Слава Україні May 02 '11 at 11:37
There is no difference, at least for MySQL.
See: http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html

- 22,336
- 11
- 85
- 113
Both are used in SQL Server. Both are used for same purpose. SQL Server 2000 and its previous version don't support != but SQL Server 2005 and SQL Server 2008 supports both <> and !=

- 11,191
- 12
- 43
- 59
Functionally there's no difference.
I think this is a matter of programmer preference: '<>' may be preferred by programmers who use various flavors of Pascal or Basic, while '!=' may be preferred by those who use languages which are descendants of C (e.g. C++, Java, C#). Interestingly, though, the C-style equality comparison operator ('==') is not supported in Oracle - how about in other flavors of SQL?
Share and enjoy.

- 48,992
- 9
- 77
- 110