To: personal-kdbplus@googlegroups.comX-Mailer: Apple Mail (2.1278)> I have a base table and multiple details table. I want to link a column of my base table to one of the details tables based on the column entry.> > q)t1:( id:104 105; t:ab; v:4.4 5.5)> q)ta:(id:enlist 104; w:aa)\> q)tb:([]id:enlist 105; w:bb)> > Now I want to create a link tlink in t1 that will link t1.id to t2.id if t=a and t1.id to t2.id if t=b.i don’t think this is doable while staying in 3nflinking columns have to link to a single table to workyou could of course put the details in key-value form instead:q)td:(id:104 105;t:ab;w:aabb)q)update tlink:td!(idt#td)?([]id;t)fromt1;q)t1id t v tlink---------------104 a 4.4 0 105 b 5.5 1 q)update tlink.w from t1id t v tlink w ------------------104 a 4.4 0 aa105 b 5.5 1 bbq)but that may or may not gain you anything over just having w in t1 in the first place
Message-Id: <7CBC86A3-B898-4449-8155-38878E4905EF@gmail.com>
Cc: “personal-kdbplus@googlegroups.com” X-Mailer: iPad Mail (10A403) From: Ray Subject: Re: [personal kdb+] linking column to different tables Date: Sun, 4 Nov 2012 21:04:20 -0500 To: “personal-kdbplus@googlegroups.com”
This is a fairly common usage in SQL and could be done inside a subquery sin= ce the problem posed implies that the id values are unique, e.g.=20
select x.id, x.text, s.text from tx x=20 join=20 (select y.id, y.text=20 from ty y union select z.id, z.text from tz z ) s on s.id =3D.x.id
Thanks for the replies. Yeah this was a ridiculous question. I ended up just creating multiple tables with common key columns that they can be joined against. Tans