Go to the first, previous, next, last section, table of contents.


Comparison operators.

Returns 1 (TRUE), 0 (FALSE) or NULL. These functions work for both numbers and strings. MySQL uses the following rules to decide how the compare is done:

If one or both of the arguments are NULL the result of the comparison is NULL.

=
Equal.
mysql> select 1 = 0;                    ->      0
mysql> select '0' = 0;                  ->      1
mysql> select '0.0' = 0;                ->      1
mysql> select '0.01' = 0;               ->      0
mysql> select '.01' = 0.01;             ->      1
<>
!=
Not equal.
mysql> select '.01' <> '0.01';          ->      1
mysql> select .01 <> '0.01';            ->      0
mysql> select 'zapp' <> 'zappp';        ->      1
<=
Smaller than or equal.
mysql> select 0.1 <= 2;                 ->      1
<
Smaller than.
mysql> select 2 <= 2;                   ->      1
>=
Bigger than or equal.
mysql> select 2 >= 2;                   ->      1
>
Bigger than.
mysql> select 2 > 2;                    ->      0
ISNULL(A)
Returns 1 if A is NULL else 0.
mysql> select isnull(1+1);              ->      0
mysql> select isnull(1/0);              ->      1
A BETWEEN B AND C
A is bigger or equal as B and A is smaller or equal to C. Does the same thing as (A >= B AND A <= C) if all arguments are of the same type. It's the first argument (A) that decides how the comparison should be done! If A is a string expression, compare as case insensitive strings. If A is a binary string, compare as binary strings. If A is an integer expression compare as integers, else compare as reals.
mysql> select 1 between 2 and 3;        ->      0
mysql> select 'b' between 'a' and 'c';  ->      1
mysql> select 2 between 2 and '3';      ->      1
mysql> select 2 between 2 and 'x-3';    ->      0


Go to the first, previous, next, last section, table of contents.