SQL STRCMP()函數
STRCMP(str1, str2)
比較兩個字符串,如果這兩個字符串相等返回0,如果第一個參數是根據當前的排序順序比第二較小則返回-1,否則返回1。
SQL> SELECT STRCMP('MOHD', 'MOHD'); +---------------------------------------------------------+ | STRCMP('MOHD', 'MOHD') | +---------------------------------------------------------+ | 0 | +---------------------------------------------------------+ 1 row in set (0.00 sec)
另一個例子是:
SQL> SELECT STRCMP('AMOHD', 'MOHD'); +---------------------------------------------------------+ | STRCMP('AMOHD', 'MOHD') | +---------------------------------------------------------+ | -1 | +---------------------------------------------------------+ 1 row in set (0.00 sec)
讓我們來看看一個例子:
SQL> SELECT STRCMP('MOHD', 'AMOHD'); +---------------------------------------------------------+ | STRCMP('MOHD', 'AMOHD') | +---------------------------------------------------------+ | 1 | +---------------------------------------------------------+ 1 row in set (0.00 sec)