Question
· Oct 14, 2017

Multiple joins in a SQL query

HI,

I have a query like below but its syntax is not accepted by Cache.

I would like to perform a left join on two tables first and then make a inner for this result with another table.

Given the constraint that we only allow one SELECT in the query, it is possible to achieve this semantics ?

Thank for your help.

 

Select * 
FROM ( sample . employee e 
LEFT JOIN  sample . company c 
on c . id = e . id ) g
JOIN sample . vendor v
on v . %id = g . attr 

Discussion (3)0
Log in or sign up to continue

Thanks, that would work, however, I doubt its correctness.

I am kind of confused about the how Cache SQL handles the associativity between the different the join types.

If every join is inner join, that's fine, we could start from any table as the initial table to do the join.

However, in my query, there is one left join and one inner join. 

In this case, I don't expect Sample.Company could be the initial table to perform the join.

Below is the plan Cache SQL output:

• Read master map Sample.Company.IDKEY, looping on ID.

• For each row: - Read master map Sample.Employee.IDKEY, using the given idkey value.

                                - Read master map Sample.Vendor.DataMasterMap, using the given idkey value.

                                 - Output the row.

Any comment on that ? Thank for your help.