如何使用2个csv信息创建csv?

tcbh2hod  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(304)

我有两个csv表,模式为
A as (Name,X,Y,date,time,millisecond,type1)
B as (Name ,X,Y,date,time,millisecond,type2) 我要一张table C with schema (X,Y,type1,type2) 哪里 X,Y,time 表的毫秒数必须相同,可能不相同。我如何才能做到这一点?
表a:

Edp,1116,313,23/6/2020,7:25:48,637,ToBolled
    Edp,1155,313,23/6/2020,7:25:50,899,ToItaled
    Edp,1155,313,23/6/2020,7:25:51,14,ToItaled
    Edp,1198,308,23/6/2020,7:25:53,217,ToUndled
    Edp,1198,308,23/6/2020,7:25:53,323,ToUndled
    Edp,1198,308,23/6/2020,7:25:53,431,ToUndled

表b:

Edp,1155,313,23/6/2020,7:25:50,891,dou
    Edp,1198,308,23/6/2020,7:25:53,211,tri

结果表:

Edp,1155,313,23/6/2020,7:25:50,899,ToItaled,dou
 Edp,1198,308,23/6/2020,7:25:53,431,ToUndled,tri
igetnqfo

igetnqfo1#

我认为您正在寻找加入:

select a.*, b.type2
from tablea a
inner join tableb b 
    on  b.name = a.name
    and b.x    = a.x
    and b.y    = a.y
    and b.date = a.date
    and b.time = a.time

这将从两个具有相同属性的表中获取记录 (name, x, y, date, time) . 您可能需要为您的确切用例调整条件。

相关问题