Not equals
Returns true when the operands do not compare equal.
Category: comparison
SQL symbol: !=
Syntax
sql
<left> != <right>
<left> <> <right>Parameters
<left>— The value to compare. Acceptsboolean,date,decimal,float,integer,interval,nvarchar,timestamp,varbinary,varchar.<right>— The value to compare it against. It must be type-compatible with the left. Acceptsboolean,date,decimal,float,integer,interval,nvarchar,timestamp,varbinary,varchar.
Returns
Examples
sql
SELECT name FROM $planets WHERE name != 'Earth' LIMIT 3;Mercury
Venus
Mars
sql
SELECT COUNT(*) FROM $planets WHERE surface_pressure != 0;4
Signatures
boolean != boolean→ booleandate != date→ booleandate != timestamp→ booleandecimal != decimal→ booleandecimal != float→ booleandecimal != integer→ booleanfloat != decimal→ booleanfloat != float→ booleanfloat != integer→ booleaninteger != decimal→ booleaninteger != float→ booleaninteger != integer→ booleaninterval != interval→ booleannvarchar != nvarchar→ booleannvarchar != varbinary→ booleannvarchar != varchar→ booleantimestamp != date→ booleantimestamp != timestamp→ booleanvarbinary != nvarchar→ booleanvarbinary != varbinary→ booleanvarbinary != varchar→ booleanvarchar != nvarchar→ booleanvarchar != varbinary→ booleanvarchar != varchar→ boolean
Notes
!= does not mean "everything else": a row whose value is NULL answers NULL, not true, so it is dropped by the WHERE clause. Of the nine planets one has a surface pressure of 0 and four have none recorded, so surface_pressure != 0 returns four rows, not eight - OR surface_pressure IS NULL is how the unknown rows are kept.