# 比较字符串

__*STRCMP 函数*__

+ `STRCMP()`: 比较 str1 和 str2 
+ 返回值: 
  + 0 表示 str1 和 str2 是相同的 
  + -1 表示 str1 小于 str2 
  + 1 表示 str1 大于 str2
+ `=`: 测试字符串是否相等
+ 例如:
  + `SELECT strcmp('ABC','ABc'), strcmp('ABC','ABC'), strcmp('ABc','ABC');` 
  + `SELECT 'ABC' = 'ABC';` 

```
tidb> select strcmp('ABC','ABc'), strcmp('ABC','ABC'), strcmp('ABc','ABC');
+---------------------+---------------------+---------------------+
| strcmp('ABC','ABc') | strcmp('ABC','ABC') | strcmp('ABc','ABC') |
+---------------------+---------------------+---------------------+
| -1                  | 0                   | 1                   |
+---------------------+---------------------+---------------------+
1 row in set (0.00 sec)
```
---------------------------------------------------------------------------
```
tidb> select strcmp('ABC','ABc'), strcmp('ABC','ABC'), strcmp('ABc','ABC');
+---------------------+---------------------+---------------------+
| strcmp('ABC','ABc') | strcmp('ABC','ABC') | strcmp('ABc','ABC') |
+---------------------+---------------------+---------------------+
| -1                  | 0                   | 1                   |
+---------------------+---------------------+---------------------+
1 row in set (0.00 sec)
tidb> select 'ABC' = 'ABC';
+---------------+
| 'ABC' = 'ABC' |
+---------------+
| 1             |
+---------------+
1 row in set (0.00 sec)
```


