嗨,请我还是新的配置单元,我想插入数据到一个配置单元表从2个不同的表使用联接。请注意以下场景:
- table a包含拼写错误的“personid”和拼写正确的信息 "“拟人”。修复中不正确的“personid” 并将结果另存为newtablefixed 具有 (fields:userid,personid,playcount)。
提示:您需要保留好ID并替换坏ID。逻辑应该是如果 "中的“人格” 表B表中没有命中 表a badids,这是一个好的身份证,应该保持原样;否则,应将其替换为 "中的“拟人” 表a。。
我的配置单元查询:
INSERT INTO NewTableFixed
Select
case when b.badid is not null then b.goodid else a.id end as personid
FROM
TableA as a
LEFT JOIN TableB b ON b.badid = a.personid
表a的样本数据:
badid goodid
1092764 1000311
1095122 1000557
6708070 1007267
10088054 1042317
1195917 1042317
表b的样本数据:
userid personID count
1000002 1010152 4
1000002 1010160 3
1000002 1010219 2
1000002 1010683 1
1000002 1011814 32
暂无答案!
目前还没有任何答案,快来回答吧!