MySQL join query using like?

前端 未结 3 756
情深已故
情深已故 2020-11-29 07:27

I have been trying to get this working for quite a while now but it just doesn\'t seem to work, maybe it is is not even possible, what i am wanting to do is to perform a MyS

3条回答
  •  醉话见心
    2020-11-29 07:34

    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.

提交回复
热议问题