hive两张表实现like模糊匹配关联

sql 复制代码
testa表(字段a)
  aaa
  bba
  cccddd
  dddaaa

testb表(字段b)
   a
   b
   
1. 使用like+concat模糊配对
select
   a.a
from testa a ,testb b
where a like concat('%',b.b,'%')
group by a.a

2. 使用locate函数
select
   a.a
from testa a ,testb b
where locate(b.b,a.a)>0
group by a.a

3. 使用instr函数
select
   a.a
from testa a ,testb b
where instr(a.a,b.b)>0
group by a.a

3. 使用split函数
select
   a.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效率比较低最好少用

相关推荐
APItesterCris7 小时前
告别人工盯品:借助 OpenClaw 搭建商品自动监控与数据分析系统(完整实操)
大数据·数据库·数据仓库·自动化
千里码aicood13 小时前
基于Hadoop的汽车销量分析与可视化
大数据·hadoop·分布式
AbnerWright1 天前
读书笔记-数据密集型应用系统设计
数据仓库
wxchyy2 天前
手把手教你入门云计算(二):这些技术改变了世界,你也能轻松掌握
hadoop·阿里云·docker·云原生·华为云·云计算·运维开发
BD_Marathon2 天前
Hadoop组成
大数据·hadoop·分布式
zgl_200537792 天前
源代码:跨数据库通用“字段级”数据血缘解析与图形化(2/3:标注信息的拆解、检验、保存)
大数据·数据库·数据仓库·sql·数据挖掘·etl·嵌入式实时数据库
邀星月为媒2 天前
正式迁移 Gitee:core-site-hive 与 core-hive-agent 后续更新只认这两个地址
hive·hadoop·gitee
BD_Marathon2 天前
Hadoop常用端口号
java·大数据·hadoop
fastjson_3 天前
Hive 复杂数据类型
数据仓库·hive·hadoop
爱吃面的猫3 天前
大数据Hadoop之——集群环境搭建(了解)
大数据·hadoop·flume