0

Please let me know how to make many to many joins on multiple tables in R using

library (dplyr)   

(preferred) or any way. Below is my sql query of many to many joins

     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’

Example Table1

      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

Example Table2

      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 

Example Table3

      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
Mahi
  • 59
  • 1
  • 7
  • 1
    Please provide a reproducible example http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – akrun Apr 18 '15 at 17:16
  • 1
    Also, it seems you have never accepted an answer for your previous questions. If someone posts an answer that works for you, click the check mark next to that response to accept that answer. That's how SO is meant to work. – MrFlick Apr 18 '15 at 17:18
  • Thanks for correcting me. I am new to this stack overflow. – Mahi Apr 18 '15 at 17:23

0 Answers0