MySQL Comparison Operators
What are the Comparison Operators in MySQL ?
Explanation
MySQL Comparison Operators :
Comparison operator is used to compare expressions or values. The result of the comparison will be either True(1) or False(0). The following descripes the comparison operators in MySQL:
= :MySQL Equal.
mysql> select 1 = 0;
--> 0
mysql> select 0.0 = 0;
--> 1
< :MySQL Less than.
mysql> select 4.5 < 5;
--> 1
mysql> select 1.1 < 1;
--> 0
<= :MySQL Less than or equal.
mysql> select 2.2 <= 2.2;
--> 1
mysql> select 2.2 <= 2.1;
--> 0
> :MySQL Greater than.
mysql> select 7 > 2;
--> 1
mysql> select 4 > 4.1;
--> 0
>= :MySQL Greater than or equal.
mysql> select 10 >= 10;
--> 1
mysql> select 4.4 >= 4.5;
--> 0
<>, != :MySQL Not equal.
mysql> select 8 <> 8;
--> 0
mysql> select 7 != 7.7;
--> 1
MySQL expr BETWEEN min AND max :If expr is greater than or equal to min and expr is less than or equal to max, BETWEEN returns 1, otherwise it returns 0.
mysql> select 5 between 5 and 6;
--> 1
mysql> select 'N' between 'M' and 'O';
--> 1
This is same for the expr NOT BETWEEN min AND max, but Not.
MySQL GREATEST(value1,value2,...) :This operator returns the largest argument, compared with two or more arguments.
mysql> select greatest('N', 'M', 'O');
--> O
mysql> select greatest(1, 2);
--> 2
The same rule is applied in finding the LEAST().
The above Examples shows the mysql comparison operators and Their Uses.