The STRCMP function compares two strings lexicographically. It returns an integer value indicating the result of the comparison.
STRCMP(<str0>, <str1>)
| Parameter | Description |
|---|---|
<str0> | The first string to compare. Type: VARCHAR |
<str1> | The second string to compare. Type: VARCHAR |
Returns TINYINT type, indicating the comparison result:
Special cases:
SELECT strcmp('test', 'test');
+------------------------+ | strcmp('test', 'test') | +------------------------+ | 0 | +------------------------+
SELECT strcmp('test1', 'test');
+-------------------------+ | strcmp('test1', 'test') | +-------------------------+ | 1 | +-------------------------+
SELECT strcmp('test', 'test1');
+-------------------------+ | strcmp('test', 'test1') | +-------------------------+ | -1 | +-------------------------+
STRCMP