SQL select and join 4 tables
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?




mysql
add a comment |
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?




mysql
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
add a comment |
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?




mysql
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?




mysql
mysql
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
Looks fine. CUSTOMER doesn't need [ or ], that's a Microsoft SQL server syntax.
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
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%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
Looks fine. CUSTOMER doesn't need [ or ], that's a Microsoft SQL server syntax.
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
add a comment |
Looks fine. CUSTOMER doesn't need [ or ], that's a Microsoft SQL server syntax.
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
add a comment |
Looks fine. CUSTOMER doesn't need [ or ], that's a Microsoft SQL server syntax.
Looks fine. CUSTOMER doesn't need [ or ], that's a Microsoft SQL server syntax.
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
add a comment |
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
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.
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%2f53310025%2fsql-select-and-join-4-tables%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
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