How to JOIN two tables?

62 views
Skip to first unread message

samanth...@gmail.com

unread,
Mar 27, 2017, 5:37:59 AM3/27/17
to ZomboDB
Hi Eric,

I have two tables TABLE_A, TABLE_B. I have created zombodb indices on both tables independently. 
TABLE_A: custid,order_no
TABLE_B: custid,Lead_id

Now I need to join both the tables by using the 'custid' to improve the performance.

Regular SQL Query:
select A.custid, #Orders, #Leads from 
(select custid,count(distinct Order_order_no) as #Orders from TABLE_A group by custid) A
left join  (select custid,count(distinct Lead_id) as #Leads from TABLE_B group by custid)
On A.custid=B.custid

Can you please provide how the equivalent ZDB query will be like?

PS:
I did look at your answer to one of the threads, wherein you suggested OPTION at the time of creating linked index.

Probably that is not an acceptable solution to us because we can not decide what tables are to be linked at the time of index creation. We would prefer to have them 
isolated and depending on our query requirement, we will join like the way we typically do with SQL. i.e., we would prefer to decouple the indices from the query use-case.

Thanks,
Samanth

Eric Ridge

unread,
Mar 27, 2017, 7:05:48 PM3/27/17
to ZomboDB
Hi Samanth!


It talks about how you set the linking options at query time.  If you still have questions, let me know.

eric

--
You received this message because you are subscribed to the Google Groups "ZomboDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zombodb+u...@googlegroups.com.
To post to this group, send email to zom...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/zombodb/b7dd97c2-3ac3-4dde-a8be-d35a91098cca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages