sqllogical-operatorsequality

Why does SQL not use double equal (==) to mean 'A is equal to B'?


I learned that single equal sign (=) is used to represent 'A is equal to B' in SQL rather than double equal sign (==) as in many programming languages.

My understanding about this is single equal sign is usually used to 'assign' operator and double equal sign is used as a substitute to distinguish 'equal' sign from 'assign' operator.

Why does SQL not use double equal in this manner to mean equality?

Is there any historical or other reason for this?


Solution

  • SQL is a declarative language, and assignments are not typically made in SQL queries themselves. As a result, SQL doesn't have the problem of ambiguity of = meaning either assignment or equality check. As a result, there is no problem with using = to check equality. On the other hand, in a programming language such as Java, single = is used for assignments, while == is used for comparison.