请告诉我如何使用
在R中的多个表上进行多对多连接library (dplyr)
(首选)或任何方式。 下面是我的多对多连接的SQL查询
Select
A.Var1,
A.Var3,
B.Var5,
C.Var2
From
Table1 as A
Inner join Table2 as B on A.Var2=B.Var4
Inner Join Table3 as C on B.Var1=C.Var3 and B.Var2=C.Var4
Where
A.var4= ’ABC’ and
B.var3= 565 and
C.var1=’XYZ’
示例表1
Var1 Var2 Var3 Var4
TX 1 A ABC
NC 1 B ABC
SC 1 C ABC
GA 1 D ABC
CA 2 E ABC
NY 2 F EFG
GA 1 G EFG
OH 1 H EFG
示例表2
Var1 Var2 Var3 Var4
10 10 565 1
10 11 565 1
10 12 565 1
11 10 444 1
10 10 565 2
10 10 444 2
10 11 565 1
10 10 565 1
示例表3
Var1 Var2 Var3 Var4
XYZ A 10 10
XYZ B 10 10
YYZ C 10 11
XYZ E 10 10
LMN F 11 10
LMN G 11 11
LMN H 10 10
XYZ I 11 10