MySQL Forums
Forum List  »  Newbie

Re: Finding the difference between two strings
Posted by: Jay Alverson
Date: April 13, 2009 10:07AM

Something like...

mysql> set @string1 :=version();
Query OK, 0 rows affected (0.00 sec)

mysql> set @string2 := concat(version(), " Beta Testing Project");
Query OK, 0 rows affected (0.00 sec)

mysql> select @string1, @string2;
+---------------------+------------------------------------------+
| @string1            | @string2                                 |
+---------------------+------------------------------------------+
| 5.0.67-community-nt | 5.0.67-community-nt Beta Testing Project |
+---------------------+------------------------------------------+
1 row in set (0.00 sec)

mysql> select if(length(@string1)>length(@string2), replace(@string1, @string2,""), replace(@string2, @string1, "")) as "The Difference";
+-----------------------+
| The Difference        |
+-----------------------+
|  Beta Testing Project |
+-----------------------+
1 row in set (0.00 sec)

mysql>

>

Thanks, Jay

Options: ReplyQuote


Subject
Written By
Posted
Re: Finding the difference between two strings
April 13, 2009 10:07AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.