Selecting 2 column in an Inner joinQuery Optimization required - Subquery using Inner JoinReplacement for Nested SELECT statements for every row in SELECT clauseFull outer join problemsInner Joins between Subsets of the Same TableMultiple column concatenationHow to Filter values in two tables using inner join?Query with join and concatenation of one joined table's columnchanging from inner joins to left joins to include null values?Query three tables with joinQuery to collect the recent TimeSampled row using inner joins in MS SQL

Was Haile Selassie the world's only involuntary messiah?

What does "lequel" mean in this sentence, and how does the rest of its grammar operate?

Optimizing PostGIS query on table using buffered point

Car no longer starts, behaved weird before giving up

Buy cheaper bike and upgrade

Prevent function taking const std::string& from accepting 0

Two people from small group of friends want to have a "meeting" with me. The circumstances are strange and give me a bad feeling

Did Ohio pass a law granting students the right to give scientifically wrong answers consistent with their religious beliefs?

How to calculate number of sets in Sigma Algebra

How cryogenic oxygen was heated up for CM cabin repressurization?

Should I present forged documents in a Penetration Test/Red team engagement?

Is "montäglich" commonly used?

Why would one use "enter the name of the project to confirm"?

Balancing empathy and deferring to the syllabus in teaching responsibilities

Is there a way to see if a macbook had a time machine backup done?

There exists a prime p such that p | n for all n ∈ N, n > 1

Relationship between two graph optimization problems

Impacts on changing the sender domain name

Are we experiencing lower level of gravity now compared to past?

Is Segwit really safe and reduced?

Many if's with simple comparison. Feels very redundant

Why in C++ do static_cast<unsigned> of negative numbers differ if the number is constant or not

How do I activate Windows XP nowadays (in 2019)?

Python's .split() implemented in C



Selecting 2 column in an Inner join


Query Optimization required - Subquery using Inner JoinReplacement for Nested SELECT statements for every row in SELECT clauseFull outer join problemsInner Joins between Subsets of the Same TableMultiple column concatenationHow to Filter values in two tables using inner join?Query with join and concatenation of one joined table's columnchanging from inner joins to left joins to include null values?Query three tables with joinQuery to collect the recent TimeSampled row using inner joins in MS SQL






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









5


















Below are my two tables :



enter image description here



I am trying to write a query that joins these 2 tables AND returns the Source_Title and Destination_Title for the given Source ID of Result Map table.



I have tried written the query, but I can only solve one part of the puzzle not the whole thing.



SELECT Title as SourceTitle 
FROM Result Map AS RM
INNER JOIN Table_Result TR ON RM.SourceId = TR.Id


The above query gives me the title for the source, but not the Destination title.










share|improve this question

































    5


















    Below are my two tables :



    enter image description here



    I am trying to write a query that joins these 2 tables AND returns the Source_Title and Destination_Title for the given Source ID of Result Map table.



    I have tried written the query, but I can only solve one part of the puzzle not the whole thing.



    SELECT Title as SourceTitle 
    FROM Result Map AS RM
    INNER JOIN Table_Result TR ON RM.SourceId = TR.Id


    The above query gives me the title for the source, but not the Destination title.










    share|improve this question





























      5













      5









      5


      1






      Below are my two tables :



      enter image description here



      I am trying to write a query that joins these 2 tables AND returns the Source_Title and Destination_Title for the given Source ID of Result Map table.



      I have tried written the query, but I can only solve one part of the puzzle not the whole thing.



      SELECT Title as SourceTitle 
      FROM Result Map AS RM
      INNER JOIN Table_Result TR ON RM.SourceId = TR.Id


      The above query gives me the title for the source, but not the Destination title.










      share|improve this question
















      Below are my two tables :



      enter image description here



      I am trying to write a query that joins these 2 tables AND returns the Source_Title and Destination_Title for the given Source ID of Result Map table.



      I have tried written the query, but I can only solve one part of the puzzle not the whole thing.



      SELECT Title as SourceTitle 
      FROM Result Map AS RM
      INNER JOIN Table_Result TR ON RM.SourceId = TR.Id


      The above query gives me the title for the source, but not the Destination title.







      sql-server t-sql






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 11 at 8:38







      Benjamin

















      asked Sep 11 at 8:26









      BenjaminBenjamin

      1554 bronze badges




      1554 bronze badges























          2 Answers
          2






          active

          oldest

          votes


















          9



















          Benjamin.
          If I understood you correctly, you want something like this:



          SELECT TR1.Title AS SourceTitle, 
          TR2.Title AS DestinationTitle
          FROM [Result Map] AS RM
          INNER JOIN Table_Result TR1 ON RM.Source_Id=TR1.Id
          INNER JOIN Table_Result TR2 ON tr2.Id=RM.destination_id;


          The query will return



          SourceTitle DestinationTitle
          ABC DEF





          share|improve this answer




























          • my explanation was not clear 100%, but the query gives me exactly what I was looking for.

            – Benjamin
            Sep 11 at 8:49


















          8



















          First, don't worry it's not just you. This trips up newcomers to SQL all the time. I see it so often. It's almost an inevitable part of SQL learning.



          I'll try to do it in words. George K has already answered with the suitable code.



          The trick is to not think of Table_Result as a table from which you extract titles.



          This inevitably leads to you writing:




          FROM results table
          INNER JOIN Table with titles in
          ON a join for which you can't find the appropriate logic


          You need to think in terms of the function the table serves in your context. Which is twofold in your case. Title of source, and title of destination.



          Which gives you a query looking more like:




          FROM result table
          INNER JOIN table from which you will extract source title
          ON join which allows you to retrieve a source title
          INNER JOIN table from which you will extract destination title
          ON join which allows you to retrieve a destination title





          share|improve this answer



























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "182"
            ;
            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/4.0/"u003ecc by-sa 4.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%2fdba.stackexchange.com%2fquestions%2f248503%2fselecting-2-column-in-an-inner-join%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown


























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            9



















            Benjamin.
            If I understood you correctly, you want something like this:



            SELECT TR1.Title AS SourceTitle, 
            TR2.Title AS DestinationTitle
            FROM [Result Map] AS RM
            INNER JOIN Table_Result TR1 ON RM.Source_Id=TR1.Id
            INNER JOIN Table_Result TR2 ON tr2.Id=RM.destination_id;


            The query will return



            SourceTitle DestinationTitle
            ABC DEF





            share|improve this answer




























            • my explanation was not clear 100%, but the query gives me exactly what I was looking for.

              – Benjamin
              Sep 11 at 8:49















            9



















            Benjamin.
            If I understood you correctly, you want something like this:



            SELECT TR1.Title AS SourceTitle, 
            TR2.Title AS DestinationTitle
            FROM [Result Map] AS RM
            INNER JOIN Table_Result TR1 ON RM.Source_Id=TR1.Id
            INNER JOIN Table_Result TR2 ON tr2.Id=RM.destination_id;


            The query will return



            SourceTitle DestinationTitle
            ABC DEF





            share|improve this answer




























            • my explanation was not clear 100%, but the query gives me exactly what I was looking for.

              – Benjamin
              Sep 11 at 8:49













            9















            9











            9









            Benjamin.
            If I understood you correctly, you want something like this:



            SELECT TR1.Title AS SourceTitle, 
            TR2.Title AS DestinationTitle
            FROM [Result Map] AS RM
            INNER JOIN Table_Result TR1 ON RM.Source_Id=TR1.Id
            INNER JOIN Table_Result TR2 ON tr2.Id=RM.destination_id;


            The query will return



            SourceTitle DestinationTitle
            ABC DEF





            share|improve this answer
















            Benjamin.
            If I understood you correctly, you want something like this:



            SELECT TR1.Title AS SourceTitle, 
            TR2.Title AS DestinationTitle
            FROM [Result Map] AS RM
            INNER JOIN Table_Result TR1 ON RM.Source_Id=TR1.Id
            INNER JOIN Table_Result TR2 ON tr2.Id=RM.destination_id;


            The query will return



            SourceTitle DestinationTitle
            ABC DEF






            share|improve this answer















            share|improve this answer




            share|improve this answer








            edited Sep 11 at 8:43









            Akina

            8,3321 gold badge5 silver badges12 bronze badges




            8,3321 gold badge5 silver badges12 bronze badges










            answered Sep 11 at 8:41









            George KGeorge K

            1,9818 silver badges20 bronze badges




            1,9818 silver badges20 bronze badges















            • my explanation was not clear 100%, but the query gives me exactly what I was looking for.

              – Benjamin
              Sep 11 at 8:49

















            • my explanation was not clear 100%, but the query gives me exactly what I was looking for.

              – Benjamin
              Sep 11 at 8:49
















            my explanation was not clear 100%, but the query gives me exactly what I was looking for.

            – Benjamin
            Sep 11 at 8:49





            my explanation was not clear 100%, but the query gives me exactly what I was looking for.

            – Benjamin
            Sep 11 at 8:49













            8



















            First, don't worry it's not just you. This trips up newcomers to SQL all the time. I see it so often. It's almost an inevitable part of SQL learning.



            I'll try to do it in words. George K has already answered with the suitable code.



            The trick is to not think of Table_Result as a table from which you extract titles.



            This inevitably leads to you writing:




            FROM results table
            INNER JOIN Table with titles in
            ON a join for which you can't find the appropriate logic


            You need to think in terms of the function the table serves in your context. Which is twofold in your case. Title of source, and title of destination.



            Which gives you a query looking more like:




            FROM result table
            INNER JOIN table from which you will extract source title
            ON join which allows you to retrieve a source title
            INNER JOIN table from which you will extract destination title
            ON join which allows you to retrieve a destination title





            share|improve this answer






























              8



















              First, don't worry it's not just you. This trips up newcomers to SQL all the time. I see it so often. It's almost an inevitable part of SQL learning.



              I'll try to do it in words. George K has already answered with the suitable code.



              The trick is to not think of Table_Result as a table from which you extract titles.



              This inevitably leads to you writing:




              FROM results table
              INNER JOIN Table with titles in
              ON a join for which you can't find the appropriate logic


              You need to think in terms of the function the table serves in your context. Which is twofold in your case. Title of source, and title of destination.



              Which gives you a query looking more like:




              FROM result table
              INNER JOIN table from which you will extract source title
              ON join which allows you to retrieve a source title
              INNER JOIN table from which you will extract destination title
              ON join which allows you to retrieve a destination title





              share|improve this answer




























                8















                8











                8









                First, don't worry it's not just you. This trips up newcomers to SQL all the time. I see it so often. It's almost an inevitable part of SQL learning.



                I'll try to do it in words. George K has already answered with the suitable code.



                The trick is to not think of Table_Result as a table from which you extract titles.



                This inevitably leads to you writing:




                FROM results table
                INNER JOIN Table with titles in
                ON a join for which you can't find the appropriate logic


                You need to think in terms of the function the table serves in your context. Which is twofold in your case. Title of source, and title of destination.



                Which gives you a query looking more like:




                FROM result table
                INNER JOIN table from which you will extract source title
                ON join which allows you to retrieve a source title
                INNER JOIN table from which you will extract destination title
                ON join which allows you to retrieve a destination title





                share|improve this answer














                First, don't worry it's not just you. This trips up newcomers to SQL all the time. I see it so often. It's almost an inevitable part of SQL learning.



                I'll try to do it in words. George K has already answered with the suitable code.



                The trick is to not think of Table_Result as a table from which you extract titles.



                This inevitably leads to you writing:




                FROM results table
                INNER JOIN Table with titles in
                ON a join for which you can't find the appropriate logic


                You need to think in terms of the function the table serves in your context. Which is twofold in your case. Title of source, and title of destination.



                Which gives you a query looking more like:




                FROM result table
                INNER JOIN table from which you will extract source title
                ON join which allows you to retrieve a source title
                INNER JOIN table from which you will extract destination title
                ON join which allows you to retrieve a destination title






                share|improve this answer













                share|improve this answer




                share|improve this answer










                answered Sep 11 at 8:58









                JerbJerb

                5952 silver badges9 bronze badges




                5952 silver badges9 bronze badges































                    draft saved

                    draft discarded















































                    Thanks for contributing an answer to Database Administrators 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.

                    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%2fdba.stackexchange.com%2fquestions%2f248503%2fselecting-2-column-in-an-inner-join%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

                    Tamil (spriik) Luke uk diar | Nawigatjuun

                    Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                    Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?