STRCMP()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns -1
, 0
, or 1
indicating the order of two string arguments.
USAGE
STRCMP(string, string)
Argument Name | Description |
---|---|
| The two strings to compare |
DETAILS
STRCMP()
is a string function that returns -1
, 0
, or 1
to indicate the ordinality of two strings.
The return value is 0
if the two arguments are equal in the current sort order. For instance, some sort orders ignore case.
The return value is -1
if the first argument sorts prior to the second based on the current sort order.
The return value is 1
if the first argument sorts after the second based on the current sort order.
A NULL
is returned if any argument is NULL
.
For a way to compare numbers and other non-string values, see CMP().
EXAMPLES
SELECT STRCMP('abc', 'ABC');
+----------------------+
| STRCMP('abc', 'ABC') |
+----------------------+
| 0 |
+----------------------+
SELECT STRCMP('abcd', 'abc');
+-----------------------+
| STRCMP('abcd', 'abc') |
+-----------------------+
| 1 |
+-----------------------+
SELECT STRCMP('abcd', 'cdef');
+------------------------+
| STRCMP('abcd', 'cdef') |
+------------------------+
| -1 |
+------------------------+