MySQL STRCMP() Function
❮ MySQL Functions
Example
Compare two strings:
SELECT STRCMP("SQL Tutorial",
"SQL Tutorial");
Try it Yourself »
Definition and Usage
The STRCMP() function tests whether two strings are the same.
Syntax
Parameter Values
Parameter |
Description |
string1 and string2 |
Required. The two strings to compare |
Note
- If string1 and string2 are the same, the
STRCMP() function returns 0
- If string1 is smaller than string2, the
STRCMP() function returns -1
- If string1 is large than string2, the
STRCMP() function returns 1
Technical Details
Works in: |
MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL
4.0, MySQL 3.23 |
More Examples
Example
Compare two strings:
SELECT STRCMP("SQL Tutorial",
"HTML Tutorial");
Try it Yourself »
❮ MySQL Functions