sql compare strings – How to compare two strings in SQL?

sql compare strings STRCMP() function in MySQL is used to compare two strings. Here is the syntax to use STRCMP () function:

sql compare strings

Compare two strings: SQL stands for Structured Query Language. In SQL, we can compare two strings using STRCMP () function. It returns 0 if both of the strings are same and returns -1.

Syntax and parameters:

SELECT column_name1, column_name2, …
FROM table_name1
WHERE column_name1:: [varchar, text] comparison_operator [>,<,=,!=,...] comparision_expression :: [varchar, text]

MySQL STRCMP() Function

SELECT STRCMP("Example Article", "Example Article");

SQL Query to Compare Two Strings

DECLARE @Player1 VARCHAR(30), @Player2 VARCHAR(20);
Set @Player1='pakainfo';
Set @Player2='pakainfoforpakainfo';
If @Player1=@Player2 Select 'match' else Select 'not match';

STRCMP() function

Select STRCMP('pakainfo', 'pakainf') As 'Cmp_Value'

don't Miss : How To Compare Two Strings In PHP If Condition?

I hope you get an idea about sql compare strings.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment