跳转到主要内容

Comparison Operators

Comparison operators.

Syntax

OperatorSyntaxDescription
=a = ba is equal to b.
!=a != ba is not equal to b.
<>a <> ba is not equal to b.
>a > ba is greater than b.
>=a >= ba is greater than or equal to b.
<a < ba is less than b.
<=a <= ba is less than or equal to b.

Examples

SELECT 1=1;
+---------+
| (1 = 1) |
+---------+
| 1 |
+---------+

SELECT 2>=1;
+----------+
| (2 >= 1) |
+----------+
| 1 |
+----------+

SELECT 2>1;
+---------+
| (2 > 1) |
+---------+
| 1 |
+---------+

SELECT 2 <= 1;
+----------+
| (2 <= 1) |
+----------+
| 0 |
+----------+

SELECT 1 < 2;
+---------+
| (1 < 2) |
+---------+
| 1 |
+---------+

SELECT '.01' != '0.01';
+-------------------+
| ('.01' <> '0.01') |
+-------------------+
| 1 |
+-------------------+

SELECT '.01' <> '0.01';
+-------------------+
| ('.01' <> '0.01') |
+-------------------+
| 1 |
+-------------------+