Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare string data between two tables

i have two tables TABLE 1 with columns

ID Text           email ID
============================
1  This is Test   [email protected]    
2  Make my day    [email protected]

TABLE 2 with one column

words(column)
=============    
Test    
trip    
day

now wat i want to do is compare the text ( each and every word) from Table 1 with each row ow word in TABLE 2, if found then the id should be logged on a different table.

example: if from TABLE1 Test is the word which is the row value in the TABLE 2 word column. so it should log ID =1 in a different table.

also once the word is found it shouldn't go for further iteration.

like image 721
tulajaram kulkarni Avatar asked Sep 21 '26 10:09

tulajaram kulkarni


1 Answers

try this:

select *
from TABLE1 
join 
TABLE2
on ' '+Text+' ' like '% '+words+' %'


SQL fiddle demo

like image 166
Joe G Joseph Avatar answered Sep 23 '26 04:09

Joe G Joseph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!