MySQL join query using like?
Solution 1:
Try
SELECT *
FROM Table1
INNER JOIN Table2 ON Table1.col LIKE CONCAT('%', Table2.col, '%')
MySQL does string concatenation differently from other databases, so in case you want to port your app, you need to have an alternate version where ||
is used as concatenation operator, as mentioned by Michael in another answer. This operator doesn't work in MySQL though, since it means or
.
Solution 2:
How about this instead:
SELECT * FROM Table1, Table2 WHERE Table1.col LIKE '%'+Table2.col+'%';
Since you're selecting everything from both tables anyway, this would probably get you there.