bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

MySQL STRCMP() Function

Concept visual

MySQL STRCMP() Function

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

Example

Compare two strings:

SELECT STRCMP("SQL Tutorial",
"SQL Tutorial");

Definition and Usage

The STRCMP() function compares two strings.

Syntax

Strcmp(

string1, string2 )

Parameter Values

Parameter

Description string1, string2 Required. The two strings to be compared

Return Values

If string1

= string2, this function returns 0

If string1

<

Formula

string2, this function returns - 1

If string1

> string2, this function returns 1

Technical Details

Works in:

From MySQL 4.0

More Examples

Example

Compare two strings:

SELECT STRCMP("SQL Tutorial",
"HTML Tutorial");

Previous

❮ MySQL Functions

Next

Previous

MySQL SPACE() Function

Next

MySQL SUBSTR() Function