cancel
Showing results for 
Search instead for 
Did you mean: 

Complicated SQL join

Former Member
0 Kudos

For an interface with a JDBC sender, I have 4 tables that need to be joined. For this question, I'll call them tab1,tab2,tab3 and tab4.

I have to join tab1 and tab2 on UNIT where flag = N. This is fine but then I have to join this result with tab3 if the UNIT found in the first join is in tab3 and the flag is = N. I also have to join tab4 to the first join if the UNIT found in the first join is in tab4 and the flag is = N. I've tried using LEFT JOIN but this is no good as it retrieves the UNIT from tab3 and tab4 regardless of the flag being equal to N or Y.

Can anyone suggest a way to do this join?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

looks like it is a good candidate for a stored procedure on DB ?!

Answers (1)

Answers (1)

ravi_raman2
Active Contributor
0 Kudos

you can write the select statement, properly written inner and outer joins should fix it.......let me know if its not clear

Regards

Ravi