SQL - list of merged contend of two (joined) tables [duplicate]
This question already has an answer here:
Selecting all items in one table and join with another table, allowing nulls
4 answers
team,
i am currently lost ..
what i wanna do is a kind of JOIN, however a SELECT using a JOIN will skip rows when the condition is emty ...
an UNION will end in an error-message as the select over T1 comes with 4 and T2 with 2 lines in my example below:
T1: Name Ort
----------------------
Markus München
Christian Berlin
Hubert Frankfurt
Kalle Düsseldorf
T2
Ort Anmerkung
-----------------------
München Bayern
Frankfurt Hessen
Outcome what i wanna archive are all 4 lines from T1 including the information from T2 (when exists) - compared/joined over "Ort".
Result:
T1.Name T1.Ort T2.Anmerkung
------------------------------
Markus München Bayern
Christian Berlin
Hubert Frankfurt Hessen
Kalle Düsseldorf
mysql sql join union
marked as duplicate by Shadow
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 23:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Selecting all items in one table and join with another table, allowing nulls
4 answers
team,
i am currently lost ..
what i wanna do is a kind of JOIN, however a SELECT using a JOIN will skip rows when the condition is emty ...
an UNION will end in an error-message as the select over T1 comes with 4 and T2 with 2 lines in my example below:
T1: Name Ort
----------------------
Markus München
Christian Berlin
Hubert Frankfurt
Kalle Düsseldorf
T2
Ort Anmerkung
-----------------------
München Bayern
Frankfurt Hessen
Outcome what i wanna archive are all 4 lines from T1 including the information from T2 (when exists) - compared/joined over "Ort".
Result:
T1.Name T1.Ort T2.Anmerkung
------------------------------
Markus München Bayern
Christian Berlin
Hubert Frankfurt Hessen
Kalle Düsseldorf
mysql sql join union
marked as duplicate by Shadow
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 23:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
correct same solution. my search in the forum did not route me to -> "..join with another table, allowing nulls". honestly, even whe soution is same the question would not point direct to the same from scratch...
– R.S.
Nov 21 '18 at 22:32
add a comment |
This question already has an answer here:
Selecting all items in one table and join with another table, allowing nulls
4 answers
team,
i am currently lost ..
what i wanna do is a kind of JOIN, however a SELECT using a JOIN will skip rows when the condition is emty ...
an UNION will end in an error-message as the select over T1 comes with 4 and T2 with 2 lines in my example below:
T1: Name Ort
----------------------
Markus München
Christian Berlin
Hubert Frankfurt
Kalle Düsseldorf
T2
Ort Anmerkung
-----------------------
München Bayern
Frankfurt Hessen
Outcome what i wanna archive are all 4 lines from T1 including the information from T2 (when exists) - compared/joined over "Ort".
Result:
T1.Name T1.Ort T2.Anmerkung
------------------------------
Markus München Bayern
Christian Berlin
Hubert Frankfurt Hessen
Kalle Düsseldorf
mysql sql join union
This question already has an answer here:
Selecting all items in one table and join with another table, allowing nulls
4 answers
team,
i am currently lost ..
what i wanna do is a kind of JOIN, however a SELECT using a JOIN will skip rows when the condition is emty ...
an UNION will end in an error-message as the select over T1 comes with 4 and T2 with 2 lines in my example below:
T1: Name Ort
----------------------
Markus München
Christian Berlin
Hubert Frankfurt
Kalle Düsseldorf
T2
Ort Anmerkung
-----------------------
München Bayern
Frankfurt Hessen
Outcome what i wanna archive are all 4 lines from T1 including the information from T2 (when exists) - compared/joined over "Ort".
Result:
T1.Name T1.Ort T2.Anmerkung
------------------------------
Markus München Bayern
Christian Berlin
Hubert Frankfurt Hessen
Kalle Düsseldorf
This question already has an answer here:
Selecting all items in one table and join with another table, allowing nulls
4 answers
mysql sql join union
mysql sql join union
asked Nov 20 '18 at 23:15
R.S.R.S.
1
1
marked as duplicate by Shadow
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 23:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Shadow
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 23:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
correct same solution. my search in the forum did not route me to -> "..join with another table, allowing nulls". honestly, even whe soution is same the question would not point direct to the same from scratch...
– R.S.
Nov 21 '18 at 22:32
add a comment |
correct same solution. my search in the forum did not route me to -> "..join with another table, allowing nulls". honestly, even whe soution is same the question would not point direct to the same from scratch...
– R.S.
Nov 21 '18 at 22:32
correct same solution. my search in the forum did not route me to -> "..join with another table, allowing nulls". honestly, even whe soution is same the question would not point direct to the same from scratch...
– R.S.
Nov 21 '18 at 22:32
correct same solution. my search in the forum did not route me to -> "..join with another table, allowing nulls". honestly, even whe soution is same the question would not point direct to the same from scratch...
– R.S.
Nov 21 '18 at 22:32
add a comment |
1 Answer
1
active
oldest
votes
Use LEFT JOIN. It will keep records from the first table that don't have a corresponding row in the second table.
select t1.name, t1.ort, t2.anmerkung
from t1
left join t2 on t1.ort=t2.ort
many thanks Kristjan .. i had a look at w3schools.com/sql/sql_join.asp , but did not see the solution on the left side. great, many thansk again!
– R.S.
Nov 21 '18 at 22:27
Happy to help. :D Since you are new at this site, we encurage you to upvote/accept answers that help you. That way good and helpful answers are distinguished and are more likely to help other users with similar problems to solve.
– Kristjan Kica
Nov 21 '18 at 23:44
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use LEFT JOIN. It will keep records from the first table that don't have a corresponding row in the second table.
select t1.name, t1.ort, t2.anmerkung
from t1
left join t2 on t1.ort=t2.ort
many thanks Kristjan .. i had a look at w3schools.com/sql/sql_join.asp , but did not see the solution on the left side. great, many thansk again!
– R.S.
Nov 21 '18 at 22:27
Happy to help. :D Since you are new at this site, we encurage you to upvote/accept answers that help you. That way good and helpful answers are distinguished and are more likely to help other users with similar problems to solve.
– Kristjan Kica
Nov 21 '18 at 23:44
add a comment |
Use LEFT JOIN. It will keep records from the first table that don't have a corresponding row in the second table.
select t1.name, t1.ort, t2.anmerkung
from t1
left join t2 on t1.ort=t2.ort
many thanks Kristjan .. i had a look at w3schools.com/sql/sql_join.asp , but did not see the solution on the left side. great, many thansk again!
– R.S.
Nov 21 '18 at 22:27
Happy to help. :D Since you are new at this site, we encurage you to upvote/accept answers that help you. That way good and helpful answers are distinguished and are more likely to help other users with similar problems to solve.
– Kristjan Kica
Nov 21 '18 at 23:44
add a comment |
Use LEFT JOIN. It will keep records from the first table that don't have a corresponding row in the second table.
select t1.name, t1.ort, t2.anmerkung
from t1
left join t2 on t1.ort=t2.ort
Use LEFT JOIN. It will keep records from the first table that don't have a corresponding row in the second table.
select t1.name, t1.ort, t2.anmerkung
from t1
left join t2 on t1.ort=t2.ort
edited Nov 20 '18 at 23:23
answered Nov 20 '18 at 23:17
Kristjan KicaKristjan Kica
2,2341926
2,2341926
many thanks Kristjan .. i had a look at w3schools.com/sql/sql_join.asp , but did not see the solution on the left side. great, many thansk again!
– R.S.
Nov 21 '18 at 22:27
Happy to help. :D Since you are new at this site, we encurage you to upvote/accept answers that help you. That way good and helpful answers are distinguished and are more likely to help other users with similar problems to solve.
– Kristjan Kica
Nov 21 '18 at 23:44
add a comment |
many thanks Kristjan .. i had a look at w3schools.com/sql/sql_join.asp , but did not see the solution on the left side. great, many thansk again!
– R.S.
Nov 21 '18 at 22:27
Happy to help. :D Since you are new at this site, we encurage you to upvote/accept answers that help you. That way good and helpful answers are distinguished and are more likely to help other users with similar problems to solve.
– Kristjan Kica
Nov 21 '18 at 23:44
many thanks Kristjan .. i had a look at w3schools.com/sql/sql_join.asp , but did not see the solution on the left side. great, many thansk again!
– R.S.
Nov 21 '18 at 22:27
many thanks Kristjan .. i had a look at w3schools.com/sql/sql_join.asp , but did not see the solution on the left side. great, many thansk again!
– R.S.
Nov 21 '18 at 22:27
Happy to help. :D Since you are new at this site, we encurage you to upvote/accept answers that help you. That way good and helpful answers are distinguished and are more likely to help other users with similar problems to solve.
– Kristjan Kica
Nov 21 '18 at 23:44
Happy to help. :D Since you are new at this site, we encurage you to upvote/accept answers that help you. That way good and helpful answers are distinguished and are more likely to help other users with similar problems to solve.
– Kristjan Kica
Nov 21 '18 at 23:44
add a comment |
correct same solution. my search in the forum did not route me to -> "..join with another table, allowing nulls". honestly, even whe soution is same the question would not point direct to the same from scratch...
– R.S.
Nov 21 '18 at 22:32