Posted inMysql

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.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype