Home » MySQL String STRCMP() Function

MySQL String STRCMP() Function

by Online Tutorials Library

MySQL STRCMP() Function

The strcmp() is a String function of MySQL. This function compares the given two strings. This function returns 0 if both the strings are same, -1 if the first string is smaller than second else it returns 1.

Syntax

Parameters:

Str1 and str2: two strings to be compared

Returns:

  • If both the strings are same, this function will return 0.
  • If str1 is smaller than str2, this function will return -1.
  • If str1 is larger than str2, this function will return 1.

Example 1

Output:

MySQL String STRCMP() Function

Example 2

Output:

MySQL String STRCMP() Function

Example 3

Output:

MySQL String STRCMP() Function

Next TopicMySQL String

You may also like