Tuesday 2 August 2016

STRCMP: Compare two strings



STRCMP(str1, str2): It compare str1, str2 and return
0: If str1 is equal to str2.
-1: If str1 is less than str2
1: If str1 is greater than str2.

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

mysql> SELECT STRCMP("banana", "apple");
+---------------------------+
| STRCMP("banana", "apple") |
+---------------------------+
|                         1 |
+---------------------------+
1 row in set (0.00 sec)

mysql> SELECT STRCMP("apple", "banana");
+---------------------------+
| STRCMP("apple", "banana") |
+---------------------------+
|                        -1 |
+---------------------------+
1 row in set (0.00 sec)




Previous                                                 Next                                                 Home

No comments:

Post a Comment