SQL select and join 4 tables












-1















I'm new to SQL, trying to join 4 tables pictured below:



Here's what I have, but I don't currently have access to the SQL server (its down, and I don't own it so I just have to wait).



SELECT customerName, address, address2, postalCode, phone, country, city 
FROM [CUSTOMER] C JOIN ADDRESS A ON C.addressId = A.addressId
JOIN CITY I ON A.cityId = I.cityId
JOIN COUNTRY P ON P.countryId = I.countryId");


Is this the proper way to join my tables?



city table



country table



customer table



address table










share|improve this question























  • Yes. Why? Btw. please edit your question and provide table structures in text form. There is absolutelly no good reason to use pictures just to post text, only downsides - ie content of pictures can't be indexed by search engines.

    – rsm
    Nov 14 '18 at 23:16
















-1















I'm new to SQL, trying to join 4 tables pictured below:



Here's what I have, but I don't currently have access to the SQL server (its down, and I don't own it so I just have to wait).



SELECT customerName, address, address2, postalCode, phone, country, city 
FROM [CUSTOMER] C JOIN ADDRESS A ON C.addressId = A.addressId
JOIN CITY I ON A.cityId = I.cityId
JOIN COUNTRY P ON P.countryId = I.countryId");


Is this the proper way to join my tables?



city table



country table



customer table



address table










share|improve this question























  • Yes. Why? Btw. please edit your question and provide table structures in text form. There is absolutelly no good reason to use pictures just to post text, only downsides - ie content of pictures can't be indexed by search engines.

    – rsm
    Nov 14 '18 at 23:16














-1












-1








-1








I'm new to SQL, trying to join 4 tables pictured below:



Here's what I have, but I don't currently have access to the SQL server (its down, and I don't own it so I just have to wait).



SELECT customerName, address, address2, postalCode, phone, country, city 
FROM [CUSTOMER] C JOIN ADDRESS A ON C.addressId = A.addressId
JOIN CITY I ON A.cityId = I.cityId
JOIN COUNTRY P ON P.countryId = I.countryId");


Is this the proper way to join my tables?



city table



country table



customer table



address table










share|improve this question














I'm new to SQL, trying to join 4 tables pictured below:



Here's what I have, but I don't currently have access to the SQL server (its down, and I don't own it so I just have to wait).



SELECT customerName, address, address2, postalCode, phone, country, city 
FROM [CUSTOMER] C JOIN ADDRESS A ON C.addressId = A.addressId
JOIN CITY I ON A.cityId = I.cityId
JOIN COUNTRY P ON P.countryId = I.countryId");


Is this the proper way to join my tables?



city table



country table



customer table



address table







mysql






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 23:02









JoeJoe

1278




1278













  • Yes. Why? Btw. please edit your question and provide table structures in text form. There is absolutelly no good reason to use pictures just to post text, only downsides - ie content of pictures can't be indexed by search engines.

    – rsm
    Nov 14 '18 at 23:16



















  • Yes. Why? Btw. please edit your question and provide table structures in text form. There is absolutelly no good reason to use pictures just to post text, only downsides - ie content of pictures can't be indexed by search engines.

    – rsm
    Nov 14 '18 at 23:16

















Yes. Why? Btw. please edit your question and provide table structures in text form. There is absolutelly no good reason to use pictures just to post text, only downsides - ie content of pictures can't be indexed by search engines.

– rsm
Nov 14 '18 at 23:16





Yes. Why? Btw. please edit your question and provide table structures in text form. There is absolutelly no good reason to use pictures just to post text, only downsides - ie content of pictures can't be indexed by search engines.

– rsm
Nov 14 '18 at 23:16












1 Answer
1






active

oldest

votes


















1














Looks fine. CUSTOMER doesn't need [ or ], that's a Microsoft SQL server syntax.






share|improve this answer
























  • Alright, I was just going off of what I read here: dofactory.com/sql/join

    – Joe
    Nov 14 '18 at 23:05






  • 1





    Probably best not to use the SO people to validate SQL, its a bit lazy. Install a MySQL locally or use db-fiddle.com / sqlfiddle.com / dbfiddle.uk to experiment with.

    – danblack
    Nov 14 '18 at 23:20











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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310025%2fsql-select-and-join-4-tables%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









1














Looks fine. CUSTOMER doesn't need [ or ], that's a Microsoft SQL server syntax.






share|improve this answer
























  • Alright, I was just going off of what I read here: dofactory.com/sql/join

    – Joe
    Nov 14 '18 at 23:05






  • 1





    Probably best not to use the SO people to validate SQL, its a bit lazy. Install a MySQL locally or use db-fiddle.com / sqlfiddle.com / dbfiddle.uk to experiment with.

    – danblack
    Nov 14 '18 at 23:20
















1














Looks fine. CUSTOMER doesn't need [ or ], that's a Microsoft SQL server syntax.






share|improve this answer
























  • Alright, I was just going off of what I read here: dofactory.com/sql/join

    – Joe
    Nov 14 '18 at 23:05






  • 1





    Probably best not to use the SO people to validate SQL, its a bit lazy. Install a MySQL locally or use db-fiddle.com / sqlfiddle.com / dbfiddle.uk to experiment with.

    – danblack
    Nov 14 '18 at 23:20














1












1








1







Looks fine. CUSTOMER doesn't need [ or ], that's a Microsoft SQL server syntax.






share|improve this answer













Looks fine. CUSTOMER doesn't need [ or ], that's a Microsoft SQL server syntax.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 23:04









danblackdanblack

2,1621319




2,1621319













  • Alright, I was just going off of what I read here: dofactory.com/sql/join

    – Joe
    Nov 14 '18 at 23:05






  • 1





    Probably best not to use the SO people to validate SQL, its a bit lazy. Install a MySQL locally or use db-fiddle.com / sqlfiddle.com / dbfiddle.uk to experiment with.

    – danblack
    Nov 14 '18 at 23:20



















  • Alright, I was just going off of what I read here: dofactory.com/sql/join

    – Joe
    Nov 14 '18 at 23:05






  • 1





    Probably best not to use the SO people to validate SQL, its a bit lazy. Install a MySQL locally or use db-fiddle.com / sqlfiddle.com / dbfiddle.uk to experiment with.

    – danblack
    Nov 14 '18 at 23:20

















Alright, I was just going off of what I read here: dofactory.com/sql/join

– Joe
Nov 14 '18 at 23:05





Alright, I was just going off of what I read here: dofactory.com/sql/join

– Joe
Nov 14 '18 at 23:05




1




1





Probably best not to use the SO people to validate SQL, its a bit lazy. Install a MySQL locally or use db-fiddle.com / sqlfiddle.com / dbfiddle.uk to experiment with.

– danblack
Nov 14 '18 at 23:20





Probably best not to use the SO people to validate SQL, its a bit lazy. Install a MySQL locally or use db-fiddle.com / sqlfiddle.com / dbfiddle.uk to experiment with.

– danblack
Nov 14 '18 at 23:20




















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310025%2fsql-select-and-join-4-tables%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

List item for chat from Array inside array React Native

Thiostrepton

Caerphilly