Comparison operators are useful in a query language to filter data with SELECT statement or modify selected records with UPDATE statement. These are used to compare values and expressions and return Boolean values 0 or 1. If comparison is true then 1 is returned else 0 is returned by these operators. MySQL comparison operators are binary that is each operator requires two operands, values or expressions. The MySQL Comparison Operators are discussed in detail below.
Equal (=)
The Equal operator return 1 if the left side value or expression is equal to the right side value or right side expression’s evaluated value. If the compared values are different then = operator returns 0.
Greater than (>)
This operator return 1 if the left side value or left side expression value is greater than the right side value or right side expression’s value. If the left side value is less or equal to right side value then this operator returns 0.
Greater than or equal (>=)
The Greater than or equal operator return 1 if the left side value or expression evaluates to a value is greater than or equal to the right side value or right expression’s value. If the left side value is less than the right side value then this operator returns 0.
Less than (<)
This operator return 1 if the left side value or left expression value is less than the right side value or right expression’s evaluated value. If the left side value is greater or equal to right side value then this operator returns 0.
Less than or equal (<=)
The Less than or equal operator returns 1 if the left side value or left expression’s value is less than or equal to the right value or right expression’s value. If the left side value is greater than the right side value then this operator returns 0.
Not equal (<> / !=)
This operator is opposite of equal to operator. It returns 1 if the left side value or expression value is not equal to the right side value or right expression’s evaluated value. If the compared values are same then this operator returns 0.
NULL-safe equal to (<=>)
The NULL-safe equal to operator behaves just like =operator. The only difference is that it returns 1 when both operands are NULL. It returns 0 if one of the operands is NULL.