STRCMP(expr1,expr2) : STRCMP « String Functions « MySQL Tutorial






STRCMP() returns 0 if the strings are the same.

STRCMP() returns -1 if the first argument is smaller than the second according to the current sort order.

STRCMP() returns 1 otherwise.

mysql> SELECT STRCMP('text', 'text2');
+-------------------------+
| STRCMP('text', 'text2') |
+-------------------------+
|                      -1 |
+-------------------------+
1 row in set (0.00 sec)

mysql> SELECT STRCMP('text2', 'text');
+-------------------------+
| STRCMP('text2', 'text') |
+-------------------------+
|                       1 |
+-------------------------+
1 row in set (0.00 sec)

mysql> SELECT STRCMP('text', 'text');
+------------------------+
| STRCMP('text', 'text') |
+------------------------+
|                      0 |
+------------------------+
1 row in set (0.00 sec)








23.41.STRCMP
23.41.1.STRCMP(expr1,expr2)
23.41.2.Using STRCMP to compare the first_name