how to use left join to have data in sibgle table from different table
I am using a left join to get data into a single table with one query, I have done this for two different table and am now writing a single query to fetch data into a single one. My query is:
select ec.CUSTOMERDESCRIPTOR as OUTLET,
ollastsyncdatetime.TIMESTMP as LASTSYNCEDDATETIME,
ollastindentdatetime.TIMESTMP as LASTINDENTDATETIME
from (ollastsyncdatetime
left join ollastindentdatetime on ((ollastsyncdatetime.OUTLET = ollastindentdatetime.OUTLET)))
Inner Join ecustomer ec on ollastsyncdatetime.outlet = ec.CUSTOMERIDENTIFIER
group by ollastsyncdatetime.OUTLET
This query is giving me a result like this:
I am able to join two tables but facing issues in joining more than two.
Now I have 2 more tables in my Database from which I have to fetch data and make new columns
the two new tables are
- ollastdumpdamagedatetime
- ollastindentdatetime
I want a result like this:
if there is no data in table it should show blank because I am populating columns data on the comparison with outlets. Please ignore the actual data in table; they are same because I am using this as an example only.
Please any body who can guide me this will be very helpful.
mysql
add a comment |
I am using a left join to get data into a single table with one query, I have done this for two different table and am now writing a single query to fetch data into a single one. My query is:
select ec.CUSTOMERDESCRIPTOR as OUTLET,
ollastsyncdatetime.TIMESTMP as LASTSYNCEDDATETIME,
ollastindentdatetime.TIMESTMP as LASTINDENTDATETIME
from (ollastsyncdatetime
left join ollastindentdatetime on ((ollastsyncdatetime.OUTLET = ollastindentdatetime.OUTLET)))
Inner Join ecustomer ec on ollastsyncdatetime.outlet = ec.CUSTOMERIDENTIFIER
group by ollastsyncdatetime.OUTLET
This query is giving me a result like this:
I am able to join two tables but facing issues in joining more than two.
Now I have 2 more tables in my Database from which I have to fetch data and make new columns
the two new tables are
- ollastdumpdamagedatetime
- ollastindentdatetime
I want a result like this:
if there is no data in table it should show blank because I am populating columns data on the comparison with outlets. Please ignore the actual data in table; they are same because I am using this as an example only.
Please any body who can guide me this will be very helpful.
mysql
add a comment |
I am using a left join to get data into a single table with one query, I have done this for two different table and am now writing a single query to fetch data into a single one. My query is:
select ec.CUSTOMERDESCRIPTOR as OUTLET,
ollastsyncdatetime.TIMESTMP as LASTSYNCEDDATETIME,
ollastindentdatetime.TIMESTMP as LASTINDENTDATETIME
from (ollastsyncdatetime
left join ollastindentdatetime on ((ollastsyncdatetime.OUTLET = ollastindentdatetime.OUTLET)))
Inner Join ecustomer ec on ollastsyncdatetime.outlet = ec.CUSTOMERIDENTIFIER
group by ollastsyncdatetime.OUTLET
This query is giving me a result like this:
I am able to join two tables but facing issues in joining more than two.
Now I have 2 more tables in my Database from which I have to fetch data and make new columns
the two new tables are
- ollastdumpdamagedatetime
- ollastindentdatetime
I want a result like this:
if there is no data in table it should show blank because I am populating columns data on the comparison with outlets. Please ignore the actual data in table; they are same because I am using this as an example only.
Please any body who can guide me this will be very helpful.
mysql
I am using a left join to get data into a single table with one query, I have done this for two different table and am now writing a single query to fetch data into a single one. My query is:
select ec.CUSTOMERDESCRIPTOR as OUTLET,
ollastsyncdatetime.TIMESTMP as LASTSYNCEDDATETIME,
ollastindentdatetime.TIMESTMP as LASTINDENTDATETIME
from (ollastsyncdatetime
left join ollastindentdatetime on ((ollastsyncdatetime.OUTLET = ollastindentdatetime.OUTLET)))
Inner Join ecustomer ec on ollastsyncdatetime.outlet = ec.CUSTOMERIDENTIFIER
group by ollastsyncdatetime.OUTLET
This query is giving me a result like this:
I am able to join two tables but facing issues in joining more than two.
Now I have 2 more tables in my Database from which I have to fetch data and make new columns
the two new tables are
- ollastdumpdamagedatetime
- ollastindentdatetime
I want a result like this:
if there is no data in table it should show blank because I am populating columns data on the comparison with outlets. Please ignore the actual data in table; they are same because I am using this as an example only.
Please any body who can guide me this will be very helpful.
mysql
mysql
edited Nov 12 '18 at 9:58
Nick
24.4k91735
24.4k91735
asked Nov 12 '18 at 9:46
manish thakurmanish thakur
39712
39712
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Use left join for both table
select ec.CUSTOMERDESCRIPTOR as OUTLET,ollastsyncdatetime.TIMESTMP as LASTSYNCEDDATETIME,ollastindentdatetime.TIMESTMP as LASTINDENTDATETIME
from ollastsyncdatetime left join ollastindentdatetime
on ollastsyncdatetime.OUTLET = ollastindentdatetime.OUTLET
left Join ecustomer ec
on ollastsyncdatetime.outlet = ec.CUSTOMERIDENTIFIER
it is giving me only 3 columns not all five
– manish thakur
Nov 12 '18 at 9:55
@could you please add your 3 tables sample data in your question
– fa06
Nov 12 '18 at 10:00
actually i have got the idea from your answer ...now i ll try by my own. :)
– manish thakur
Nov 12 '18 at 10:02
@manishthakur, that's great
– fa06
Nov 12 '18 at 10:02
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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
});
}
});
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%2fstackoverflow.com%2fquestions%2f53259492%2fhow-to-use-left-join-to-have-data-in-sibgle-table-from-different-table%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use left join for both table
select ec.CUSTOMERDESCRIPTOR as OUTLET,ollastsyncdatetime.TIMESTMP as LASTSYNCEDDATETIME,ollastindentdatetime.TIMESTMP as LASTINDENTDATETIME
from ollastsyncdatetime left join ollastindentdatetime
on ollastsyncdatetime.OUTLET = ollastindentdatetime.OUTLET
left Join ecustomer ec
on ollastsyncdatetime.outlet = ec.CUSTOMERIDENTIFIER
it is giving me only 3 columns not all five
– manish thakur
Nov 12 '18 at 9:55
@could you please add your 3 tables sample data in your question
– fa06
Nov 12 '18 at 10:00
actually i have got the idea from your answer ...now i ll try by my own. :)
– manish thakur
Nov 12 '18 at 10:02
@manishthakur, that's great
– fa06
Nov 12 '18 at 10:02
add a comment |
Use left join for both table
select ec.CUSTOMERDESCRIPTOR as OUTLET,ollastsyncdatetime.TIMESTMP as LASTSYNCEDDATETIME,ollastindentdatetime.TIMESTMP as LASTINDENTDATETIME
from ollastsyncdatetime left join ollastindentdatetime
on ollastsyncdatetime.OUTLET = ollastindentdatetime.OUTLET
left Join ecustomer ec
on ollastsyncdatetime.outlet = ec.CUSTOMERIDENTIFIER
it is giving me only 3 columns not all five
– manish thakur
Nov 12 '18 at 9:55
@could you please add your 3 tables sample data in your question
– fa06
Nov 12 '18 at 10:00
actually i have got the idea from your answer ...now i ll try by my own. :)
– manish thakur
Nov 12 '18 at 10:02
@manishthakur, that's great
– fa06
Nov 12 '18 at 10:02
add a comment |
Use left join for both table
select ec.CUSTOMERDESCRIPTOR as OUTLET,ollastsyncdatetime.TIMESTMP as LASTSYNCEDDATETIME,ollastindentdatetime.TIMESTMP as LASTINDENTDATETIME
from ollastsyncdatetime left join ollastindentdatetime
on ollastsyncdatetime.OUTLET = ollastindentdatetime.OUTLET
left Join ecustomer ec
on ollastsyncdatetime.outlet = ec.CUSTOMERIDENTIFIER
Use left join for both table
select ec.CUSTOMERDESCRIPTOR as OUTLET,ollastsyncdatetime.TIMESTMP as LASTSYNCEDDATETIME,ollastindentdatetime.TIMESTMP as LASTINDENTDATETIME
from ollastsyncdatetime left join ollastindentdatetime
on ollastsyncdatetime.OUTLET = ollastindentdatetime.OUTLET
left Join ecustomer ec
on ollastsyncdatetime.outlet = ec.CUSTOMERIDENTIFIER
answered Nov 12 '18 at 9:53
fa06fa06
11.4k2917
11.4k2917
it is giving me only 3 columns not all five
– manish thakur
Nov 12 '18 at 9:55
@could you please add your 3 tables sample data in your question
– fa06
Nov 12 '18 at 10:00
actually i have got the idea from your answer ...now i ll try by my own. :)
– manish thakur
Nov 12 '18 at 10:02
@manishthakur, that's great
– fa06
Nov 12 '18 at 10:02
add a comment |
it is giving me only 3 columns not all five
– manish thakur
Nov 12 '18 at 9:55
@could you please add your 3 tables sample data in your question
– fa06
Nov 12 '18 at 10:00
actually i have got the idea from your answer ...now i ll try by my own. :)
– manish thakur
Nov 12 '18 at 10:02
@manishthakur, that's great
– fa06
Nov 12 '18 at 10:02
it is giving me only 3 columns not all five
– manish thakur
Nov 12 '18 at 9:55
it is giving me only 3 columns not all five
– manish thakur
Nov 12 '18 at 9:55
@could you please add your 3 tables sample data in your question
– fa06
Nov 12 '18 at 10:00
@could you please add your 3 tables sample data in your question
– fa06
Nov 12 '18 at 10:00
actually i have got the idea from your answer ...now i ll try by my own. :)
– manish thakur
Nov 12 '18 at 10:02
actually i have got the idea from your answer ...now i ll try by my own. :)
– manish thakur
Nov 12 '18 at 10:02
@manishthakur, that's great
– fa06
Nov 12 '18 at 10:02
@manishthakur, that's great
– fa06
Nov 12 '18 at 10:02
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2fstackoverflow.com%2fquestions%2f53259492%2fhow-to-use-left-join-to-have-data-in-sibgle-table-from-different-table%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