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)