我有两张桌子。
表:gender_age_train
index chinese latin_brands
---------- ---------- ------------
1 三星 samsung
2 天语 Ktouch
3 海信 hisense
4 联想 lenovo
5 欧比 obi
6 爱派尔 ipair
7 努比亚 nubia
8 优米 youmi
9 朵唯 dowe
10 黑米 heymi
表:chinese_latin_translation
phone_brand
如果品牌中有中文字母并且来自gender_age_train
列的翻译,我如何替换表latin_brands
中的phone_brand
?
如果翻译可用,我想要替换不是completly列,只替换行。
数据集有超过1十亿行。此案例中的重要列仅为latin_brands
和SELECT latin_brands, phone_brand FROM gender_age_brand_train LEFT JOIN chinese_latin_translation on gender_age_brand_train.phone_brand = chinese
示例查询:
NSFileCoordinator
答案 0 :(得分:0)
在介于:chinese_latin_translation和gender_age_train
之间使用left join
select
A.index,
A.Unnamed,
A.device_id,
A.gender,
A.age,
A.group,
coalesce(B.latin_brands,A.phone_brand) as brand
from
gender_age_train A
left join chinese_latin_translation B on
A.phone_brand= B.chinese
答案 1 :(得分:0)
这应该适合您的req,Inner join with update Row
UPDATE T2
SET T2. Name = T1 .Name
FROM gender_age_train as T2 INNER JOIN Table1 as T1
ON T1. Id = T1 .Id;
现在你可以设置你的查询。