What does <> do in the following WHERE clause,
WHERE posn_id <> rid
What does <> do in the following WHERE clause,
WHERE posn_id <> rid
WHERE posn_id <> rid
Will return all rows where both posn_id and rid are not NULL and where they are different.
It's the ANSI SQL-Compliant not equals operator in a simple comparison predicate (WHERE statement). Colloquially, it's the "inequality operator". Though many databases accept an alternative !=, the spec itself does not mention != and it should not be used if <> is supported.
SQL uses three valued logic, with possible values being true, false or unknown. The WHERE clause filters out all rows except those where the predicate evaluates to true.
null, the operator returns unknown.=, the operator returns true.<> returns false.On null treatment, a similar operator is IS DISTINCT FROM which treats nulls as ordinary values, from the PostgreSQL docs
For non-null inputs,
IS DISTINCT FROMis the same as the<>operator. However, if both inputs arenullit returns false, and if only one input isnullit returns true.
For RDBMS specific documentation on comparison operators, see also
It's just another way of spelling the "not equals" operator, an alternative to !=