The STRCMP()
function compares two strings sent as a parameter.
Figure 1 shows a visual representation of the STRCMP()
function.
STRCMP(str1, str2)
The STRCMP()
function takes two strings as a parameter.
The STRCMP()
function compares two strings sent as a parameter.
- If both the strings are equal, then this function returns 0.
- If string-1 > string-2, then this function returns 1.
- If string-1 < string-2, then this function returns -1.
- If any of the strings is NULL, then this function returns NULL.
-- Both the strings are sameSELECT STRCMP('educative','educative');-- string-1 < string-2SELECT STRCMP('edpresso','educative');-- string-1 > string-2SELECT STRCMP('educative','edpresso');-- string-1 = NULLSELECT STRCMP(NULL,'edpresso');