Reputation: 1571
I need to match some words between two columns. I am not able to find this solution anywhere, so i need help.
|==========title=================|======title================|
|...Toscano Brioche..............|...Toscano .... ...........|
|....Toscano Brioche Creme.......|...Brioche Creme Butter....|
OUTPUT==>
|==========title=================|======title================|===OUTPUT===|
|...Toscano Brioche..............|...Toscano .... ...........| 1 |
|....Toscano Brioche Creme.......|...Brioche Creme Butter....| 1 |
|....Strawberry CAKE Bakery......|...Brioche Creme Butter....| 0 |
How to compare these two columns named 'title' in table, I need to match some words between the two columns. For example, in row 1, 'Toscano' is common in both columns, in row 2, 'Brioche Creme' is common.
Upvotes: 1
Views: 3178
Reputation: 1276
Not able to understand your question completely, I think you want to compare 2 columns, if those have some common words then show 1. May be it can help you..
select title1,title2,title1 like concat("%",replace(title2," ","%"),"%") as matched from table_name
EDIT: You can see accepted answer if these two columns are from different table. By the way that is obvious. But don't forgot to use replace as I did if you want to find all words anywhere.
Upvotes: 2