3 Replies Latest reply: Sep 22, 2017 12:17 AM by Momin Tahemas RSS

    Join

    Julien Le Berre

      Hello

       

      I would like to merge 2 tables like this:

       

      A, B

      1, xx

      2, yy

       

      A, C

      1, aa

      1, bb

      2, cc

       

      A, B, C

      1, xx, aa

      1, xx, bb

      2, yy, cc

       

      Do I have to use a left join, or another?


      thanks

        • Re: Join
          Nicole Smith

          Left join will do it.  Your code will look something like this:

           

          Table1:
          load * inline [
          A, B
          1, xx
          2, yy
          ];
          
          left join (Table1)
          load * inline [
          A, C
          1, aa
          1, bb
          2, cc
          ;
          

           

          I've also attached an example file.

          • Re: Join
            Anand Chouhan

            Yes left join worked well here

             

            A:

            LOAD * Inline

            [

            A, B

            1, xx

            2, yy

            ];

             

            Left Join(A)

            LOAD * Inline

            [

            A, C

            1, aa

            1, bb

            2, cc

            ];

            • Re: Join
              Momin Tahemas

              hi

              you can use LEFT JOIN

              Like

                  Table1: 

                  load * inline [ 

                  A, B 

                  1, xx 

                  2, yy 

                  ];  

                  left join (Table1)

                  Table2:

                  load * inline [ 

                  A, C 

                  1, aa 

                  1, bb 

                  2, cc 

                  ]; 

              output:

              A B C
              1xxaa
              1xxbb
              2yycc

               

              Regards

              Tahemas Momin