MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to do a SQL type operation???


Here is a DIY solution :

In[1]:=myJoin[t1_List,t2_List,keyPosition_:1]:=
    Module[{sel},
      sel[x_]:=Rest@First@Select[t2,#[[1]] == x&];
      Join[#,sel[#[[keyPosition]]]]& /@ t1
      ];

Example :

In[2]:=t1={{1,11},{2,21},{2,22},{3,31},{4,41}};

In[3]:=t2={{1,211,212},{2,221,222},{3,231,232},{4,241,242}};

In[4]:=myJoin[t1,t2]

Out[4]={{1,11,211,212},{2,21,221,222},{2,22,221,222},{3,31,231,232},{4,41,241,242}}


hth

v.a.


  • Prev by Date: Re: Descarta2D
  • Next by Date: Re: Awesome PDF writer
  • Previous by thread: Re: How to do a SQL type operation???
  • Next by thread: Re: How to do a SQL type operation???