Not Equal in SQL
Not Equal in SQL
To test if two values are not equal, SQL provides a few operators:
Common Not Equal Operators:
| Operator | Meaning | Supported By |
|---|---|---|
<> | Not equal to | Most SQL databases (ANSI standard) |
!= | Not equal to | MySQL, SQL Server, PostgreSQL, Oracle (also supports <>) |
^= | Not equal to | Some SQL Server versions (less common) |
? Syntax Examples:
SELECT * FROM employeesWHERE salary <> 50000;or
SELECT * FROM employeesWHERE salary != 50000;Notes:
Both
<>and!=work in most modern SQL databases, but<>is the ANSI SQL standard.Use whichever is supported by your database and consistent with your style.
If you want, I can show you examples with other comparison operators!