STRCMP()

Overview

Returns -1, 0, or 1 indicating the order of two string arguments.

USAGE

STRCMP(string, string)

Argument Name

Description

string

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().

SYNONYMS

SCHEMA

PARAMETERS

SKYSQL

PRIVILEGES

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 |
+------------------------+

ERROR HANDLING

FEATURE INTERACTION

RESPONSES

DIAGNOSIS

ISO 9075:2016

CHANGE HISTORY

Release Series

History

23.09

  • Present starting in MariaDB Xpand 23.09.1.

6.1

  • Present starting in MariaDB Xpand 6.1.0.

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.1

  • Present starting in MariaDB Xpand 6.1.0.

EXTERNAL REFERENCES