Asked 2 years ago
31 May 2022
Views 660
steave

steave posted

how to use function STRCMP in MySQL?

how to use STRCMP in MySQL ? can you please explain function STRCMP in MySQL with some example?
web-api

web-api
answered May 31 '22 00:00

The STRCMP function is used to check the equality of two strings in MySQL.
syntax :
STRCMP(str1,str2)
here str1 and str2 is string

what is the return of the STRCMP based on the given string ?
if str1 and str2 are the same or equal(case insensitive check), it will return 0
if str1 is greater than str2, it will return 1
if str1 is small than str2, it will return 1

examples


select STRCMP("arrayoverflow","arrayoverflow")  
// return  is 0




select STRCMP("arrayoverflow","Arrayoverflow")  
// return  is 0



select STRCMP("arrayoverflow.com","arrayoverflow")  
// return  is 1




select STRCMP("arrayoverflow.com","arrayoverflow.com")  
// return  is -1



select STRCMP("z","a") 
// return  is 1



select
STRCMP("a","z") 
// return  is 1

Post Answer