The correct term for what you are looking for is "conditional join". In SAP HANA the term "dynamic join" is used very differently.
I edited your question accordingly and added some formatting as well.
What's missing from your question is a minimal example to work against. This would include CREATE TABLE statements for the tables and INSERT commands for the data.
Without those, it's a lot more work for everyone to work through your requirements and see if the solution is working correctly.
This time I put in time and effort myself to provide a solution that (hopefully) does what you want. For further questions, please make it easier for the folks who like to help you and do that yourself.
select current_timestamp, * from m_database;
/*
CURRENT_TIMESTAMP SYSTEM_ID DATABASE_NAME HOST START_TIME VERSION USAGE
2019-03-21 01:05:19.827 HXE HXE hxehost 2019-03-21 00:18:01.659 2.00.035.00.1545187853 DEVELOPMENT
*/
create column table tab_a (f1 integer, f2 integer, f3 integer);
create column table tab_b (f4 integer, f5 integer, f6 integer);
create column table tab_c (f7 integer, f8 integer);
create column table tab_d (f9 integer, f10 integer, f11 integer);
-- A
insert into tab_a values (10, 12, 13);
insert into tab_a values (20, 22, 23);
insert into tab_a values (30, 22, 23);
insert into tab_a values (50, 52, 53);
select * from tab_a;
/*
F1 F2 F3
10 12 13
20 22 23
30 22 23
50 52 53
*/
-- B
insert into tab_b values (10, 120, 130);
insert into tab_b values (20, 220, 230);
insert into tab_b values (30, 230, 230);
insert into tab_b values (50, 500, NULL); // <- join case with f6 IS NULL
select * from tab_b;
/*
F4 F5 F6
10 120 130
20 220 230
30 230 230
50 500 ?
*/
-- C
insert into tab_c values (120, 1200);
insert into tab_c values (220, 2200);
insert into tab_c values (230, 2200);
select * from tab_c;
/*
F7 F8
120 1200
220 2200
230 2200
*/
-- D
insert into tab_d values (3001, 50, 1);
insert into tab_d values (20, 2200, 999 );
insert into tab_d values (30, 2200, 999 );
insert into tab_d values (230, 2200, 999 );
insert into tab_d values (130, 1200, 999 );
select * from tab_d;
/*
F9 F10 F11
3001 50 1
20 2200 999
30 2200 999
230 2200 999
130 1200 999
*/
-- orig
SELECT a.f1
, a.f2
, a.f3
, c.f7
, c.f8
FROM
tab_a a
INNER JOIN tab_b b
ON b.f4 = a.f1
LEFT OUTER JOIN tab_c c
ON c.f7 = b.f5
WHERE
a.f1 IN (10, 20, 30, 50);
/*
F1 F2 F3 F7 F8
10 12 13 120 1200
20 22 23 220 2200
30 22 23 230 2200
50 52 53 ? ?
*/
Up to here the code just reproduces your example and the SQL you posted. Note, how the "special" case with "f1" = 50 stands out with the NULLs in F7 and F8.
Now, while SAP HANA supports a feature called "case"-join (which can be used to conditionally join to different tables), the straight forward approach for your requirement is to perform two OUTER JOIN.
This works well as your condition results in two mutually exclusive cases: either TABLE_B."f6" IS NULL or not.
To map the two sets of resulting columns into a single set in the projection we can use either COALESCE or IFNULL functions to get the correct set of columns.
-- new
SELECT a.f1
, a.f2
, a.f3
, c.f7
, c.f8
, coalesce(d1.f9, d2.f9) f9_cond
, coalesce(d1.f11, d2.f11) f11_cond
FROM
tab_a a
INNER JOIN tab_b b
ON b.f4 = a.f1
LEFT OUTER JOIN tab_c c
ON c.f7 = b.f5
LEFT OUTER JOIN tab_d d1
ON b.f6 IS NOT NULL
AND b.f6 = d1.f9
LEFT OUTER JOIN tab_d d2
ON b.f6 IS NULL
AND d2.f11 = 1
AND b.f4 = d2.f10
WHERE
a.f1 IN (10, 20, 30, 50);
/*
F1 F2 F3 F7 F8 F9_COND F11_COND
10 12 13 120 1200 130 999
20 22 23 220 2200 230 999
30 22 23 230 2200 230 999
50 52 53 ? ? 3001 1
*/
Note that this is standard SQL and not related to how SAP HANA works. A quick search with the correct term "conditional join" would have delivered plenty of results for this.