Lets say I have
(def test-left
[{:name "Sean" :age 27}
{:name "Ross" :age 27}
{:name "Brian" :age 22}])
and
(def test-right
[{:owner "Sean" :item "Beer"}
{:owner "Sean" :item "Pizza"}
{:owner "Ross" :item "Computer"}
{:owner "Matt" :item "Bike"}])
When I do a (clojure.set/join test-left test-right)
I get a Cartesian product. 12 rows. What I want is Inner-join on :name of left = :owner of right so that I get only those result which have matching rows in the right side
So I get
[{:name "Sean" :age 27 :item “Beer” }
{:name "Sean" :age 27 :item “Pizza” }
{:name "Ross" :age 27 :item “Computer”}]
Any Ideas. Similarly Would like to achieve left and right outer joins but that is separete question. I am learning clojure so please bear with me
Got it . My Bad
1:24 main-hta=> (clojure.set/join test-left test-right {:name :owner})
gets
#{{:item "Pizza", :owner "Sean", :name "Sean", :age 27} {:item "Beer", :owner "Sean", :name "Sean", :age 27} {:item "Computer", :owner "Ross", :name "Ross", :ag
e 27}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With