English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
You can use the 'strcmp()' function to check the similarity between two strings. This is the condition.
If the two strings are equal, it returns 0.
If the first string is less than the second string, it returns-1.
If the first string is greater than the second string, it returns1.
This is an example.
Case1-If the two strings are equal.
The following is the query.
mysql > SELECT STRCMP("demo", "demo");
The following is the output of the above query.
+------------------------+ | STRCMP("demo", "demo") | +------------------------+ | 0 | +------------------------+ 1 row in set (0.00 sec)
Case2-If the first string is less than the second string.
The following is the query.
SELECT STRCMP("demo", "demo"1234);
The following is the output of the above query.
+----------------------------+ | STRCMP("demo", "demo"1234) | +----------------------------+ | -1 | +----------------------------+ 1 row in set (0.00 sec)
Case3-If the first string is greater than the second string.
The following is the query.
SELECT STRCMP("demo"1", "demo");
The following is the output.
+-------------------------+ | STRCMP("demo"1", "demo") | +-------------------------+ | 1 | +-------------------------+ 1 row in set (0.00 sec)