How best to join tables, which have different lengths on the same column values which exist in both tables?List of different values which have to be formatted differentlyArgmax in a ListHow to create a Table of Tables with indexed variablesRelational joining of tablesHow to use ImageMultiply[] over a list of strings?What is the Mathematica way of joining two tables?Is it possible to assign different values to a list of symbol, where they have the same argument?How to create a table of tables with different table lengths?How can I pair the values in 2 different tables of the same length together to make a table with 2 variables x, y?

Independence of Mean and Variance of Discrete Uniform Distributions

Why doesn't mathematics collapse down, even though humans quite often make mistakes in their proofs?

Number of matrices with bounded products of rows and columns

Is there a commercial liquid with refractive index greater than n=2?

Have only girls been born for a long time in this village?

Are unaudited server logs admissible in a court of law?

Metal that glows when near pieces of itself

On the relation between the asymptotics of a Dirichlet series' coefficients and the series' analytic continuability

How best to join tables, which have different lengths on the same column values which exist in both tables?

Earliest evidence of objects intended for future archaeologists?

Wristwatches in the cockpit

Can sulfuric acid itself be electrolysed?

Why should I pay for an SSL certificate?

Why do balloons get cold when they deflate?

How can I train a replacement without letting my bosses and the replacement knowing?

Playing a fast but quiet Alberti bass

Did Wernher von Braun really have a "Saturn V painted as the V2"?

Where is this New York City Broadway location from Fall 1958?

Lazy brainfuck programmer

Check disk usage of files returned with spaces

Control GPIO pins from C

Expand def in write18

What is "super" in superphosphate?

Quick destruction of a helium filled airship?



How best to join tables, which have different lengths on the same column values which exist in both tables?


List of different values which have to be formatted differentlyArgmax in a ListHow to create a Table of Tables with indexed variablesRelational joining of tablesHow to use ImageMultiply[] over a list of strings?What is the Mathematica way of joining two tables?Is it possible to assign different values to a list of symbol, where they have the same argument?How to create a table of tables with different table lengths?How can I pair the values in 2 different tables of the same length together to make a table with 2 variables x, y?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4












$begingroup$


I think my problem is pretty simple, and in SQL this would be trivial. I have two tables



TableOne = a, x1, b, x2, c, x3;
TableTwo = a, y1, c, y2 , a, y3, a, y4, b, y5, c,y6, c, y7


I want to abe able to join these two tables where the values of column 1 in both tables match such that:



DesiredResult = a, x1, a, y1, c, x3 , c, y2 , a, x1, a, y3, a, x1, a, y4, b, x2, b, y5, c, x3, c, y6, c, x3, c, y7


I've tried with both Select[] statements inside a Table[] structure and also looked into JoinAcross[] but haven't been able to acheive the desire effect. In SQL it would be simple, something like:



SELECT Col1.Table1, Col2.Table1, Col1.Table2, Col2.Table2, FROM table2 INNER JOIN table1 ON Col1.Table1 = Col1.Table2


Or something similar.










share|improve this question









$endgroup$




















    4












    $begingroup$


    I think my problem is pretty simple, and in SQL this would be trivial. I have two tables



    TableOne = a, x1, b, x2, c, x3;
    TableTwo = a, y1, c, y2 , a, y3, a, y4, b, y5, c,y6, c, y7


    I want to abe able to join these two tables where the values of column 1 in both tables match such that:



    DesiredResult = a, x1, a, y1, c, x3 , c, y2 , a, x1, a, y3, a, x1, a, y4, b, x2, b, y5, c, x3, c, y6, c, x3, c, y7


    I've tried with both Select[] statements inside a Table[] structure and also looked into JoinAcross[] but haven't been able to acheive the desire effect. In SQL it would be simple, something like:



    SELECT Col1.Table1, Col2.Table1, Col1.Table2, Col2.Table2, FROM table2 INNER JOIN table1 ON Col1.Table1 = Col1.Table2


    Or something similar.










    share|improve this question









    $endgroup$
















      4












      4








      4





      $begingroup$


      I think my problem is pretty simple, and in SQL this would be trivial. I have two tables



      TableOne = a, x1, b, x2, c, x3;
      TableTwo = a, y1, c, y2 , a, y3, a, y4, b, y5, c,y6, c, y7


      I want to abe able to join these two tables where the values of column 1 in both tables match such that:



      DesiredResult = a, x1, a, y1, c, x3 , c, y2 , a, x1, a, y3, a, x1, a, y4, b, x2, b, y5, c, x3, c, y6, c, x3, c, y7


      I've tried with both Select[] statements inside a Table[] structure and also looked into JoinAcross[] but haven't been able to acheive the desire effect. In SQL it would be simple, something like:



      SELECT Col1.Table1, Col2.Table1, Col1.Table2, Col2.Table2, FROM table2 INNER JOIN table1 ON Col1.Table1 = Col1.Table2


      Or something similar.










      share|improve this question









      $endgroup$




      I think my problem is pretty simple, and in SQL this would be trivial. I have two tables



      TableOne = a, x1, b, x2, c, x3;
      TableTwo = a, y1, c, y2 , a, y3, a, y4, b, y5, c,y6, c, y7


      I want to abe able to join these two tables where the values of column 1 in both tables match such that:



      DesiredResult = a, x1, a, y1, c, x3 , c, y2 , a, x1, a, y3, a, x1, a, y4, b, x2, b, y5, c, x3, c, y6, c, x3, c, y7


      I've tried with both Select[] statements inside a Table[] structure and also looked into JoinAcross[] but haven't been able to acheive the desire effect. In SQL it would be simple, something like:



      SELECT Col1.Table1, Col2.Table1, Col1.Table2, Col2.Table2, FROM table2 INNER JOIN table1 ON Col1.Table1 = Col1.Table2


      Or something similar.







      list-manipulation table






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 13 hours ago









      QuantumPenguinQuantumPenguin

      5743 silver badges18 bronze badges




      5743 silver badges18 bronze badges























          3 Answers
          3






          active

          oldest

          votes


















          5












          $begingroup$

          I think you should stay away from associations because your keys aren't unique. Maybe just go over all tuples of elements and pick those that match your criterion:



          Reap[Outer[If[#1[[1]] == #2[[1]], Sow@Join@##] &, TableOne, TableTwo, 1]][[2, 1]]

          (* a, x1, a, y1, a, x1, a, y3, a, x1, a, y4, b, x2, b, y5, c, x3, c, y2,
          c, x3, c, y6, c, x3, c, y7 *)





          share|improve this answer









          $endgroup$














          • $begingroup$
            That'll do it, thanks again Roman.
            $endgroup$
            – QuantumPenguin
            13 hours ago


















          3












          $begingroup$

          assocOne = AssociationThread[First /@ #, #] & @ TableOne;

          f = Join[assocOne[First @ #], #]&;

          Map[f] @ TableTwo



          a, x1, a, y1, c, x3, c, y2, a, x1, a, y3, a, x1, a, y4, b,
          x2, b, y5, c, x3, c, y6, c, x3, c, y7







          share|improve this answer









          $endgroup$














          • $begingroup$
            Also a very nice solution, +1!
            $endgroup$
            – QuantumPenguin
            8 hours ago


















          0












          $begingroup$

          Flatten[Table[Join[n, #] & /@ Cases[TableTwo, n[[1]], _], n, TableOne], 1]

          (* a, x1, a, y1, a, x1, a, y3, a, x1, a, y4, b, x2, b, y5, c,
          x3, c, y2, c, x3, c, y6, c, x3, c, y7 *)





          share|improve this answer









          $endgroup$

















            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "387"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f203913%2fhow-best-to-join-tables-which-have-different-lengths-on-the-same-column-values%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5












            $begingroup$

            I think you should stay away from associations because your keys aren't unique. Maybe just go over all tuples of elements and pick those that match your criterion:



            Reap[Outer[If[#1[[1]] == #2[[1]], Sow@Join@##] &, TableOne, TableTwo, 1]][[2, 1]]

            (* a, x1, a, y1, a, x1, a, y3, a, x1, a, y4, b, x2, b, y5, c, x3, c, y2,
            c, x3, c, y6, c, x3, c, y7 *)





            share|improve this answer









            $endgroup$














            • $begingroup$
              That'll do it, thanks again Roman.
              $endgroup$
              – QuantumPenguin
              13 hours ago















            5












            $begingroup$

            I think you should stay away from associations because your keys aren't unique. Maybe just go over all tuples of elements and pick those that match your criterion:



            Reap[Outer[If[#1[[1]] == #2[[1]], Sow@Join@##] &, TableOne, TableTwo, 1]][[2, 1]]

            (* a, x1, a, y1, a, x1, a, y3, a, x1, a, y4, b, x2, b, y5, c, x3, c, y2,
            c, x3, c, y6, c, x3, c, y7 *)





            share|improve this answer









            $endgroup$














            • $begingroup$
              That'll do it, thanks again Roman.
              $endgroup$
              – QuantumPenguin
              13 hours ago













            5












            5








            5





            $begingroup$

            I think you should stay away from associations because your keys aren't unique. Maybe just go over all tuples of elements and pick those that match your criterion:



            Reap[Outer[If[#1[[1]] == #2[[1]], Sow@Join@##] &, TableOne, TableTwo, 1]][[2, 1]]

            (* a, x1, a, y1, a, x1, a, y3, a, x1, a, y4, b, x2, b, y5, c, x3, c, y2,
            c, x3, c, y6, c, x3, c, y7 *)





            share|improve this answer









            $endgroup$



            I think you should stay away from associations because your keys aren't unique. Maybe just go over all tuples of elements and pick those that match your criterion:



            Reap[Outer[If[#1[[1]] == #2[[1]], Sow@Join@##] &, TableOne, TableTwo, 1]][[2, 1]]

            (* a, x1, a, y1, a, x1, a, y3, a, x1, a, y4, b, x2, b, y5, c, x3, c, y2,
            c, x3, c, y6, c, x3, c, y7 *)






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 13 hours ago









            RomanRoman

            15.7k1 gold badge21 silver badges52 bronze badges




            15.7k1 gold badge21 silver badges52 bronze badges














            • $begingroup$
              That'll do it, thanks again Roman.
              $endgroup$
              – QuantumPenguin
              13 hours ago
















            • $begingroup$
              That'll do it, thanks again Roman.
              $endgroup$
              – QuantumPenguin
              13 hours ago















            $begingroup$
            That'll do it, thanks again Roman.
            $endgroup$
            – QuantumPenguin
            13 hours ago




            $begingroup$
            That'll do it, thanks again Roman.
            $endgroup$
            – QuantumPenguin
            13 hours ago













            3












            $begingroup$

            assocOne = AssociationThread[First /@ #, #] & @ TableOne;

            f = Join[assocOne[First @ #], #]&;

            Map[f] @ TableTwo



            a, x1, a, y1, c, x3, c, y2, a, x1, a, y3, a, x1, a, y4, b,
            x2, b, y5, c, x3, c, y6, c, x3, c, y7







            share|improve this answer









            $endgroup$














            • $begingroup$
              Also a very nice solution, +1!
              $endgroup$
              – QuantumPenguin
              8 hours ago















            3












            $begingroup$

            assocOne = AssociationThread[First /@ #, #] & @ TableOne;

            f = Join[assocOne[First @ #], #]&;

            Map[f] @ TableTwo



            a, x1, a, y1, c, x3, c, y2, a, x1, a, y3, a, x1, a, y4, b,
            x2, b, y5, c, x3, c, y6, c, x3, c, y7







            share|improve this answer









            $endgroup$














            • $begingroup$
              Also a very nice solution, +1!
              $endgroup$
              – QuantumPenguin
              8 hours ago













            3












            3








            3





            $begingroup$

            assocOne = AssociationThread[First /@ #, #] & @ TableOne;

            f = Join[assocOne[First @ #], #]&;

            Map[f] @ TableTwo



            a, x1, a, y1, c, x3, c, y2, a, x1, a, y3, a, x1, a, y4, b,
            x2, b, y5, c, x3, c, y6, c, x3, c, y7







            share|improve this answer









            $endgroup$



            assocOne = AssociationThread[First /@ #, #] & @ TableOne;

            f = Join[assocOne[First @ #], #]&;

            Map[f] @ TableTwo



            a, x1, a, y1, c, x3, c, y2, a, x1, a, y3, a, x1, a, y4, b,
            x2, b, y5, c, x3, c, y6, c, x3, c, y7








            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 10 hours ago









            kglrkglr

            212k10 gold badges242 silver badges485 bronze badges




            212k10 gold badges242 silver badges485 bronze badges














            • $begingroup$
              Also a very nice solution, +1!
              $endgroup$
              – QuantumPenguin
              8 hours ago
















            • $begingroup$
              Also a very nice solution, +1!
              $endgroup$
              – QuantumPenguin
              8 hours ago















            $begingroup$
            Also a very nice solution, +1!
            $endgroup$
            – QuantumPenguin
            8 hours ago




            $begingroup$
            Also a very nice solution, +1!
            $endgroup$
            – QuantumPenguin
            8 hours ago











            0












            $begingroup$

            Flatten[Table[Join[n, #] & /@ Cases[TableTwo, n[[1]], _], n, TableOne], 1]

            (* a, x1, a, y1, a, x1, a, y3, a, x1, a, y4, b, x2, b, y5, c,
            x3, c, y2, c, x3, c, y6, c, x3, c, y7 *)





            share|improve this answer









            $endgroup$



















              0












              $begingroup$

              Flatten[Table[Join[n, #] & /@ Cases[TableTwo, n[[1]], _], n, TableOne], 1]

              (* a, x1, a, y1, a, x1, a, y3, a, x1, a, y4, b, x2, b, y5, c,
              x3, c, y2, c, x3, c, y6, c, x3, c, y7 *)





              share|improve this answer









              $endgroup$

















                0












                0








                0





                $begingroup$

                Flatten[Table[Join[n, #] & /@ Cases[TableTwo, n[[1]], _], n, TableOne], 1]

                (* a, x1, a, y1, a, x1, a, y3, a, x1, a, y4, b, x2, b, y5, c,
                x3, c, y2, c, x3, c, y6, c, x3, c, y7 *)





                share|improve this answer









                $endgroup$



                Flatten[Table[Join[n, #] & /@ Cases[TableTwo, n[[1]], _], n, TableOne], 1]

                (* a, x1, a, y1, a, x1, a, y3, a, x1, a, y4, b, x2, b, y5, c,
                x3, c, y2, c, x3, c, y6, c, x3, c, y7 *)






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 3 hours ago









                MelaGoMelaGo

                2,5311 gold badge1 silver badge7 bronze badges




                2,5311 gold badge1 silver badge7 bronze badges






























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Mathematica Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    Use MathJax to format equations. MathJax reference.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f203913%2fhow-best-to-join-tables-which-have-different-lengths-on-the-same-column-values%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                    Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                    Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її