Hi Mark! On Wed, Nov 20, 2013 at 01:11:11PM -0800, Mark wrote: > I'm using the 2.0 snapshot. How should I express a join on multiple > columns, ie > SELECT blah FROM t1 JOIN t2 ON (t1.a=t2.b) AND (t1.c=t2.d) ?
Something like this should work: (let [t1 (-> (table :t1) (project [:a :c])) t2 (-> (table :t2) (project [:b :d]))] (join t1 t2 :on `(and (= :a :b) (= :c :d)))) If you've got shared attributes this won't work for you, though, because then there's an ambiguity about whether to use a natural join (ie. joining on equality of shared attributes) or your join condition (which will leave an ambiguity about which shared attribute to use). In that case you can use something like this: (let [t1 (-> (table :t1) (project [:a :b])) t2 (-> (table :t2) (project [:a :c]))] (join (rename t1 (as-subobject :t1)) (rename t2 (as-subobject :t2)) :on `(and (= :t1.a :t2.c) (= :t2.a :t1.b)))) Sorry about the lack of documentation for this. I'm working on it, but I've been quite busy/distracted lately. Hopefully I'll have some more time to get back to it soon. Carlo -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.