Returns the result of comparing two strings.
Category: | String |
Returned data type: | Integer |
COMPARE(string1, string2<,case-insensitive>)
string1
a string to be used in the comparison; this can be specified as string constant, field name, or expression
string2
a string to be used in the comparison; this can be specified as string constant, field name, or expression
case-insensitive
specifies a Boolean string that indicates whether to compare case-insensitive strings; this can be specified as string constant, field name, or expression.
TRUE | specifies that the string comparison is not case sensitive. |
FALSE | specifies that the comparison is case sensitive. |
Default | FALSE |
The MATCH_STRING function compares two string lexiographically and can be used to do string comparisons using wildcards.
The return value is an integer representing the result of a lexicographical comparison of the two strings:
[-1 = string1 < string 2,
0 = string1 equals string2,
1 = string1 > string2]
To check whether two strings are equal, it is more efficient to use the == operator, for example:
if string1 == string2 then match=true
// hallo comes before hello when alphabetically sorted
rc = compare("hello", "hallo" ) // outputs 1
// Hello comes before hello when alphabetically sorted
rc = compare("Hello", "hello" ) // outputs -1
modifier = null
rc = compare("Hello", "hello", modifier ) // outputs -1
rc = compare("Hello", "hello", true ) // outputs 0