Equals
Returns true when both operands compare equal.
Category: comparison
SQL symbol: =
Syntax
sql
<left> = <right>Parameters
<left>— The value to compare. Numeric types compare across the family, so1 = 1.0is true. 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 - a number and a string are rejected rather than coerced. Acceptsboolean,date,decimal,float,integer,interval,nvarchar,timestamp,varbinary,varchar.
Returns
Examples
sql
SELECT name FROM $planets WHERE name = 'Earth';Earth
sql
SELECT 'Mars' = 'mars', 1 = 1.0, 1 = NULL;false | true | NULL
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
Comparison is three-valued: NULL on either side gives NULL, never true or false, and NULL = NULL is NULL too - IS NULL is the test for absence. String comparison is case-sensitive ('Mars' = 'mars' is false), unlike column NAMES, which are not.