[在此处输入链接描述] [1]
表1:
BRAND
索尼
苹果
谷歌
IBM
等
表2:
hive> select * from PRODUCT;
SonyABC,Applepqr 101
Sonyadvv,IBMabc 102
Sonyaaaa 103
Apple123,Sonyxyz 104
Apple345,IBMabc 105
IBM13123SonyABC 106
My data is like above.and i need output like bellow.Please suggest a query
SonyABC,Applepqr 101 Sony,Apple
Sonyadvv,IBMabc 102 Sony,IBM
Sonyaaaa 103 Sony
Apple123,Sonyxyz 104 Apple,Sony
Apple345,IBMabc 105 Apple,IBM
IBM13123,SonyABC 106 IBM,Sony
答案 0 :(得分:0)
您的数据可能存在一些问题,但其效果如下 蜂房>从BRAND中选择*; 索尼 苹果 谷歌 IBM
hive> select * from PRODUCT;
SonyABC 101
Sonyadvv 102
Sonyaaaa 103
Apple123 104
Apple345 105
IBM13123 106
select PRODUCT.*, BRAND.* from BRAND, PRODUCT where trim(PRODUCT_ID) like concat(trim(BRAND_ID),'%');
SonyABC 101 Sony
Sonyadvv 102 Sony
Sonyaaaa 103 Sony
Apple123 104 Apple
Apple345 105 Apple
IBM13123 106 IBM
Time taken: 11.381 seconds, Fetched: 6 row(s)