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;
Below are my two tables :
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
add a comment
|
Below are my two tables :
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
add a comment
|
Below are my two tables :
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
Below are my two tables :
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
sql-server t-sql
edited Sep 11 at 8:38
Benjamin
asked Sep 11 at 8:26
BenjaminBenjamin
1554 bronze badges
1554 bronze badges
add a comment
|
add a comment
|
2 Answers
2
active
oldest
votes
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
my explanation was not clear 100%, but the query gives me exactly what I was looking for.
– Benjamin
Sep 11 at 8:49
add a comment
|
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
add a comment
|
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
my explanation was not clear 100%, but the query gives me exactly what I was looking for.
– Benjamin
Sep 11 at 8:49
add a comment
|
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
my explanation was not clear 100%, but the query gives me exactly what I was looking for.
– Benjamin
Sep 11 at 8:49
add a comment
|
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
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
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
add a comment
|
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
add a comment
|
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
add a comment
|
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
add a comment
|
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
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
answered Sep 11 at 8:58
JerbJerb
5952 silver badges9 bronze badges
5952 silver badges9 bronze badges
add a comment
|
add a comment
|
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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