STR_COMPARE

Returns a numeric value indicating the relative alphabetical ordering of two strings. Returns 0 if the two strings are the same. Returns a positive number if the second string comes before the first. Returns a negative number if the second string comes after the first. The ASCII table is used for this, see examples below.

Format

STR_COMPARE (String 1, String 2)

Arguments

 
String 1
Text string.
String 2
Text string.

Examples

The following function shows that the two strings are identical. Note that the string is not case senstive.
 
Function
STR_COMPARE("adjective","adjective")
or
STR_COMPARE("ADJECTIVE","adjective")
or
STR_COMPARE("AdjEctIVe","adjective")
Result
0
The following function returns a positive number (corresponding to the difference in character order), indicating that the second string comes before the first string in ASCII character order:
 
Function
STR_COMPARE("verb","subject")
Result
3
The following function returns a negative number (corresponding to the difference in character order), indicating that the second string comes after the first string in ASCII character order:
 
Function
STR_COMPARE("varb","verb")
Result
-4