MathGroup Archive 2006

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64376] Re: How to do a SQL type operation???
  • From: "Ray Koopman" <koopman at sfu.ca>
  • Date: Wed, 15 Feb 2006 03:31:47 -0500 (EST)
  • References: <dspfnb$cf2$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Richard Palmer wrote:
> Assume Table1={{a,Xa},{b,Xb},...,{n,Xn},...} where the key a can occur many
> times and Xa is different each occurrence.
>
> We also have table2={{a,Ya},{b,Yb},...,{n,Yn}}. Here a,b,...,n occur exactly
> once.
>
> How do I create table3={{a,Xa,Ya},{b,Xb,Yb},...,{n,Xn,Yn},...} by joining
> the tables on the first column?
>
> From the problem, if a (or b or c or ...  n} is in table1, it is also in
> table1 and visa versa.
>
> The a,b,...,n,... Are small positive integers.
>
> Thanks

Module[{Y}, Scan[Y@#[[1]] = #[[2]]&, table2];
            Append[#, Y@#[[1]] ]& /@ table1]
(untested)


  • Prev by Date: Re: Awesome PDF writer
  • Next by Date: Re: Mathematica:recursion with 2 arguments?
  • Previous by thread: Re: How to do a SQL type operation???
  • Next by thread: Re: How to do a SQL type operation???