STRCMP(str1, str2)
比较两个字符串,如果这两个字符串相等返回0,如果第一个参数是根据当前的排序小于第二个参数顺序返回-1,否则返回1。
mysql> SELECT STRCMP('MOHD', 'MOHD'); +---------------------------------------------------------+ | STRCMP('MOHD', 'MOHD') | +---------------------------------------------------------+ | 0 | +---------------------------------------------------------+ 1 row in set (0.00 sec)
另一个例子是:
mysql> SELECT STRCMP('AMOHD', 'MOHD'); +---------------------------------------------------------+ | STRCMP('AMOHD', 'MOHD') | +---------------------------------------------------------+ | -1 | +---------------------------------------------------------+ 1 row in set (0.00 sec)
让我们来看看一个例子:
mysql> SELECT STRCMP('MOHD', 'AMOHD'); +---------------------------------------------------------+ | STRCMP('MOHD', 'AMOHD') | +---------------------------------------------------------+ | 1 | +---------------------------------------------------------+ 1 row in set (0.00 sec)