8 Replies Latest reply: Jul 9, 2018 6:09 AM by phuc pham RSS

    Left join within if condition

    phuc pham

      Hello everyone,

      I have practiced with data load editor but i am facing to JOIN trouble. There is an example:

       

      TableA:  

      ID CUSID BRANCH
      100A
      200B
      300C
      400D
      500E

       

      TableB:

        

      ID CUSID BRANCH
      100C
      300B

       

      I have tried Left join to create expected table like

        

      ID CUSID BRANCH
      100C
      200B
      300B
      400D
      500E

      but the trouble is using left join will generate NULL value for ID BRANCH while i am tending to combine 2 tables. There is my script

      TableA:

      LOAD

           ID CUS as ID_CUS,

           ID BRANCH as ID_BRANCH

      FROM A.xlsx;

       

      TableB:

      LOAD

           ID CUS as ID_CUS,

           ID BRANCH ID_BRANCH2

      FROM B.xlsx;

       

      LEFT JOIN (tableB)

           ID CUS as ID_CUS,

           //I have tried using alt to replace NULL value by ID_BRANCH in tableA

           //if(ID_BRANCH2 = '00C' or ID_BRANCH2='00B', ID_BRANCH2,alt())

      resident tableA;

       

      Could anyone guide me a little. Thanks in advance!