testa表(字段a)aaabbacccddddddaaatestb表(字段b)ab1. 使用like+concat模糊配对
selecta.a
from testa a ,testb b
where a like concat('%',b.b,'%')
group by a.a2. 使用locate函数
selecta.a
from testa a ,testb b
where locate(b.b,a.a)>0
group by a.a3. 使用instr函数
selecta.a
from testa a ,testb b
where instr(a.a,b.b)>0
group by a.a3. 使用split函数
selecta.a
from testa a ,testb b
where split(a.a,b.b)[1] is not null
group by a.a
注:
1.需要除重操作,比如:a表符合b两个将产生两条记录。
2.上面都会产生笛卡尔积,所以要注意数据量级。如果两个表都比较大,可以考虑将表拆分分别关联。
3.like效率比较低最好少用