webCOMAND

STRCMP()

Compare two strings lexicographically (alphabetically) and return an integer representing their relationship.

This function is multi-byte safe, and is case-sensitive.

Prototype

int STRCMP(string str1, string str2)

Parameters

  • str1 - The first string to compare.
  • str2 - The second string to compare.

Return

Returns one of four possible results:

  • 0: If both strings are equal.
  • -1: If the first string is smaller than the second string based on sorting order.
  • 1: If the first string is larger than the second string.
  • NULL: If either of the arguments is NULL.

Example

SELECT STRCMP(Username, Email) AS Comparison FROM User

Related

IN_STR()