SQL - list of merged contend of two (joined) tables [duplicate]












0
















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









share|improve this question













marked as duplicate by Shadow mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

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
















0
















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









share|improve this question













marked as duplicate by Shadow mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

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














0












0








0









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









share|improve this question















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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 23:15









R.S.R.S.

1




1




marked as duplicate by Shadow mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

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 mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

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



















  • 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












1 Answer
1






active

oldest

votes


















0














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





share|improve this answer


























  • 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


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














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





share|improve this answer


























  • 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
















0














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





share|improve this answer


























  • 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














0












0








0







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





share|improve this answer















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






share|improve this answer














share|improve this answer



share|improve this answer








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



















  • 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





這個網誌中的熱門文章

Academy of Television Arts & Sciences

L'Équipe

1995 France bombings