have a select statement with joins and unions and cant get it to work
So a mobile telephony question. Have an adjacency table listing all the source and target adjacencies. So the target cell can be an external/border cell or a normal cell. So first I want to check if the target is a normal cell and if not I want to load the list of external cells from the external cell table.
So the tables are c_adjacent_cell_4g
, the normal cell table is c_ecell
and the target cell can be from the c_ecell
table or from the c_externaleutrancellfdd
table. Note the source cell will always be a normal cell and the target cell can be a normal cell or an external cell. So to my rather poor attempt at a select statement.
SELECT INT_ID, int_id
FROM (
SELECT adj.int_id, if(src.earfcnDl = tgt.earfcnDl, 'ADJS', 'ADJI') AS TYPE
FROM C_ADJACENT_CELL_4G adj
JOIN C_ECELL src ON (src.int_id = adj.src_cell_int_id)
JOIN C_ECELL tgt ON (tgt.int_id = adj.adj_cell_int_id)
LEFT JOIN C_EXTERNALEUTRANCELLFDD tgt ON (tgt.int_id = adj.adj_cell_int_id)
WHERE src.earfcndl IS NOT NULL AND tgt.earfcndl IS NOT NULL) DATA;
Is it possible I should be using a union statement rather than a left join. Thanks.
mysql
add a comment |
So a mobile telephony question. Have an adjacency table listing all the source and target adjacencies. So the target cell can be an external/border cell or a normal cell. So first I want to check if the target is a normal cell and if not I want to load the list of external cells from the external cell table.
So the tables are c_adjacent_cell_4g
, the normal cell table is c_ecell
and the target cell can be from the c_ecell
table or from the c_externaleutrancellfdd
table. Note the source cell will always be a normal cell and the target cell can be a normal cell or an external cell. So to my rather poor attempt at a select statement.
SELECT INT_ID, int_id
FROM (
SELECT adj.int_id, if(src.earfcnDl = tgt.earfcnDl, 'ADJS', 'ADJI') AS TYPE
FROM C_ADJACENT_CELL_4G adj
JOIN C_ECELL src ON (src.int_id = adj.src_cell_int_id)
JOIN C_ECELL tgt ON (tgt.int_id = adj.adj_cell_int_id)
LEFT JOIN C_EXTERNALEUTRANCELLFDD tgt ON (tgt.int_id = adj.adj_cell_int_id)
WHERE src.earfcndl IS NOT NULL AND tgt.earfcndl IS NOT NULL) DATA;
Is it possible I should be using a union statement rather than a left join. Thanks.
mysql
Why do you selectINT_ID
twice? And what's the point of theTYPE
column in the subquery?
– Barmar
Nov 20 '18 at 21:19
You're using the aliastgt
twice. You need a different alias forC_EXTERNALEUTRANCELLFDD
– Barmar
Nov 20 '18 at 21:21
add a comment |
So a mobile telephony question. Have an adjacency table listing all the source and target adjacencies. So the target cell can be an external/border cell or a normal cell. So first I want to check if the target is a normal cell and if not I want to load the list of external cells from the external cell table.
So the tables are c_adjacent_cell_4g
, the normal cell table is c_ecell
and the target cell can be from the c_ecell
table or from the c_externaleutrancellfdd
table. Note the source cell will always be a normal cell and the target cell can be a normal cell or an external cell. So to my rather poor attempt at a select statement.
SELECT INT_ID, int_id
FROM (
SELECT adj.int_id, if(src.earfcnDl = tgt.earfcnDl, 'ADJS', 'ADJI') AS TYPE
FROM C_ADJACENT_CELL_4G adj
JOIN C_ECELL src ON (src.int_id = adj.src_cell_int_id)
JOIN C_ECELL tgt ON (tgt.int_id = adj.adj_cell_int_id)
LEFT JOIN C_EXTERNALEUTRANCELLFDD tgt ON (tgt.int_id = adj.adj_cell_int_id)
WHERE src.earfcndl IS NOT NULL AND tgt.earfcndl IS NOT NULL) DATA;
Is it possible I should be using a union statement rather than a left join. Thanks.
mysql
So a mobile telephony question. Have an adjacency table listing all the source and target adjacencies. So the target cell can be an external/border cell or a normal cell. So first I want to check if the target is a normal cell and if not I want to load the list of external cells from the external cell table.
So the tables are c_adjacent_cell_4g
, the normal cell table is c_ecell
and the target cell can be from the c_ecell
table or from the c_externaleutrancellfdd
table. Note the source cell will always be a normal cell and the target cell can be a normal cell or an external cell. So to my rather poor attempt at a select statement.
SELECT INT_ID, int_id
FROM (
SELECT adj.int_id, if(src.earfcnDl = tgt.earfcnDl, 'ADJS', 'ADJI') AS TYPE
FROM C_ADJACENT_CELL_4G adj
JOIN C_ECELL src ON (src.int_id = adj.src_cell_int_id)
JOIN C_ECELL tgt ON (tgt.int_id = adj.adj_cell_int_id)
LEFT JOIN C_EXTERNALEUTRANCELLFDD tgt ON (tgt.int_id = adj.adj_cell_int_id)
WHERE src.earfcndl IS NOT NULL AND tgt.earfcndl IS NOT NULL) DATA;
Is it possible I should be using a union statement rather than a left join. Thanks.
mysql
mysql
edited Nov 20 '18 at 21:18
Barmar
422k35244346
422k35244346
asked Nov 20 '18 at 21:03
Fintan O'HalloranFintan O'Halloran
61
61
Why do you selectINT_ID
twice? And what's the point of theTYPE
column in the subquery?
– Barmar
Nov 20 '18 at 21:19
You're using the aliastgt
twice. You need a different alias forC_EXTERNALEUTRANCELLFDD
– Barmar
Nov 20 '18 at 21:21
add a comment |
Why do you selectINT_ID
twice? And what's the point of theTYPE
column in the subquery?
– Barmar
Nov 20 '18 at 21:19
You're using the aliastgt
twice. You need a different alias forC_EXTERNALEUTRANCELLFDD
– Barmar
Nov 20 '18 at 21:21
Why do you select
INT_ID
twice? And what's the point of the TYPE
column in the subquery?– Barmar
Nov 20 '18 at 21:19
Why do you select
INT_ID
twice? And what's the point of the TYPE
column in the subquery?– Barmar
Nov 20 '18 at 21:19
You're using the alias
tgt
twice. You need a different alias for C_EXTERNALEUTRANCELLFDD
– Barmar
Nov 20 '18 at 21:21
You're using the alias
tgt
twice. You need a different alias for C_EXTERNALEUTRANCELLFDD
– Barmar
Nov 20 '18 at 21:21
add a comment |
2 Answers
2
active
oldest
votes
We could make use a UNION ALL
set operator, to combine rows from C_ECELL
and C_EXTERNALEUTRANCELLFDD
into a single set, as an inline view, and then join to the combined set:
SELECT ...
FROM C_ADJACENT_CELL_4G adj
JOIN (
SELECT 'i' AS src
, intl.int_id
, intl.earfcndl
FROM C_ECELL int
UNION ALL
SELECT 'e' AS src
, extl.int_id
, extl.earfcndl
FROM C_EXTERNALEUTRANCELLFDD extl
) tgt
ON tgt.int_id = ...
If the same value of int_id
appears in both intl
and extl
, the join operation will match both rows.
But I would avoid the UNION ALL approach. And instead do outer joins to both of the target tables. And then do a check (in an expression in the SELECT list) to determine if we found a match in C_ECELL
. If not, we must have found a match in C_EXTERNALEUTRANCELLFDD
.
Something along these lines:
SELECT adj.int_id AS _adj__int_id
, src.int_id AS _src__int_id
, tgt.int_id AS _tgt__int_id
, ext.int_id AS _ext__int_id
, src.earfcndl AS _src__earfcndl
, tgt.earfcndl AS _tgt__earfcndl
, ext.earfcndl AS _ext__earfcndl
, IF(adj.adj_cell_int_id = tgt.int_id, 'internal', 'external')
FROM C_ADJACENT_CELL_4G adj
JOIN C_ECELL src
ON src.int_id = adj.src_cell_int_id
LEFT
JOIN C_ECELL tgt
ON tgt.int_id = adj.adj_cell_int_id
LEFT
JOIN C_EXTERNALEUTRANCELLFDD ext
ON ext.int_id = adj.adj_cell_int_id
WHERE src.earfcndl IS NOT NULL
AND ( tgt.earfcndl IS NOT NULL OR ext.earfcndl IS NOT NULL )
(The condition in the WHERE clause guarantees us that we found a matching row in either tgt
or ext
; if there wasn't a matching row in either, then earfcndl
column from both outer joined tables would be NULL.)
add a comment |
You need to join with a UNION
of C_ECELL
and C_EXTERNALEUTRANCELLFDD
.
SELECT adj.int_id, if(src.earfcnDl = tgt.earfcnDl, 'ADJS', 'ADJI') AS TYPE
FROM C_ADJACENT_CELL_4G adj
JOIN C_ECELL src ON (src.int_id = adj.src_cell_int_id)
JOIN (
SELECT int_id, earfcnDl
FROM C_ECELL
WHERE earfcndl IS NOT NULL
UNION
SELECT int_id, earfcnDl
FROM C_EXTERNALEUTRANCELLFDD
WHERE earfcndl IS NOT NULL) AS tgt ON (tgt.int_id = adj.adj_cell_int_id)
WHERE src.earfcndl IS NOT NULL
Absolutely perfect. Works a treat and provides exactly what I need. So very grateful. To answer your question about the use of two int_ids in the provided select statement, the second int_id is just a dummy value to replicate a second value I do use in the select statement which I pass into the method that executes the select statement. Most happy
– Fintan O'Halloran
Nov 20 '18 at 22:01
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%2f53401498%2fhave-a-select-statement-with-joins-and-unions-and-cant-get-it-to-work%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
We could make use a UNION ALL
set operator, to combine rows from C_ECELL
and C_EXTERNALEUTRANCELLFDD
into a single set, as an inline view, and then join to the combined set:
SELECT ...
FROM C_ADJACENT_CELL_4G adj
JOIN (
SELECT 'i' AS src
, intl.int_id
, intl.earfcndl
FROM C_ECELL int
UNION ALL
SELECT 'e' AS src
, extl.int_id
, extl.earfcndl
FROM C_EXTERNALEUTRANCELLFDD extl
) tgt
ON tgt.int_id = ...
If the same value of int_id
appears in both intl
and extl
, the join operation will match both rows.
But I would avoid the UNION ALL approach. And instead do outer joins to both of the target tables. And then do a check (in an expression in the SELECT list) to determine if we found a match in C_ECELL
. If not, we must have found a match in C_EXTERNALEUTRANCELLFDD
.
Something along these lines:
SELECT adj.int_id AS _adj__int_id
, src.int_id AS _src__int_id
, tgt.int_id AS _tgt__int_id
, ext.int_id AS _ext__int_id
, src.earfcndl AS _src__earfcndl
, tgt.earfcndl AS _tgt__earfcndl
, ext.earfcndl AS _ext__earfcndl
, IF(adj.adj_cell_int_id = tgt.int_id, 'internal', 'external')
FROM C_ADJACENT_CELL_4G adj
JOIN C_ECELL src
ON src.int_id = adj.src_cell_int_id
LEFT
JOIN C_ECELL tgt
ON tgt.int_id = adj.adj_cell_int_id
LEFT
JOIN C_EXTERNALEUTRANCELLFDD ext
ON ext.int_id = adj.adj_cell_int_id
WHERE src.earfcndl IS NOT NULL
AND ( tgt.earfcndl IS NOT NULL OR ext.earfcndl IS NOT NULL )
(The condition in the WHERE clause guarantees us that we found a matching row in either tgt
or ext
; if there wasn't a matching row in either, then earfcndl
column from both outer joined tables would be NULL.)
add a comment |
We could make use a UNION ALL
set operator, to combine rows from C_ECELL
and C_EXTERNALEUTRANCELLFDD
into a single set, as an inline view, and then join to the combined set:
SELECT ...
FROM C_ADJACENT_CELL_4G adj
JOIN (
SELECT 'i' AS src
, intl.int_id
, intl.earfcndl
FROM C_ECELL int
UNION ALL
SELECT 'e' AS src
, extl.int_id
, extl.earfcndl
FROM C_EXTERNALEUTRANCELLFDD extl
) tgt
ON tgt.int_id = ...
If the same value of int_id
appears in both intl
and extl
, the join operation will match both rows.
But I would avoid the UNION ALL approach. And instead do outer joins to both of the target tables. And then do a check (in an expression in the SELECT list) to determine if we found a match in C_ECELL
. If not, we must have found a match in C_EXTERNALEUTRANCELLFDD
.
Something along these lines:
SELECT adj.int_id AS _adj__int_id
, src.int_id AS _src__int_id
, tgt.int_id AS _tgt__int_id
, ext.int_id AS _ext__int_id
, src.earfcndl AS _src__earfcndl
, tgt.earfcndl AS _tgt__earfcndl
, ext.earfcndl AS _ext__earfcndl
, IF(adj.adj_cell_int_id = tgt.int_id, 'internal', 'external')
FROM C_ADJACENT_CELL_4G adj
JOIN C_ECELL src
ON src.int_id = adj.src_cell_int_id
LEFT
JOIN C_ECELL tgt
ON tgt.int_id = adj.adj_cell_int_id
LEFT
JOIN C_EXTERNALEUTRANCELLFDD ext
ON ext.int_id = adj.adj_cell_int_id
WHERE src.earfcndl IS NOT NULL
AND ( tgt.earfcndl IS NOT NULL OR ext.earfcndl IS NOT NULL )
(The condition in the WHERE clause guarantees us that we found a matching row in either tgt
or ext
; if there wasn't a matching row in either, then earfcndl
column from both outer joined tables would be NULL.)
add a comment |
We could make use a UNION ALL
set operator, to combine rows from C_ECELL
and C_EXTERNALEUTRANCELLFDD
into a single set, as an inline view, and then join to the combined set:
SELECT ...
FROM C_ADJACENT_CELL_4G adj
JOIN (
SELECT 'i' AS src
, intl.int_id
, intl.earfcndl
FROM C_ECELL int
UNION ALL
SELECT 'e' AS src
, extl.int_id
, extl.earfcndl
FROM C_EXTERNALEUTRANCELLFDD extl
) tgt
ON tgt.int_id = ...
If the same value of int_id
appears in both intl
and extl
, the join operation will match both rows.
But I would avoid the UNION ALL approach. And instead do outer joins to both of the target tables. And then do a check (in an expression in the SELECT list) to determine if we found a match in C_ECELL
. If not, we must have found a match in C_EXTERNALEUTRANCELLFDD
.
Something along these lines:
SELECT adj.int_id AS _adj__int_id
, src.int_id AS _src__int_id
, tgt.int_id AS _tgt__int_id
, ext.int_id AS _ext__int_id
, src.earfcndl AS _src__earfcndl
, tgt.earfcndl AS _tgt__earfcndl
, ext.earfcndl AS _ext__earfcndl
, IF(adj.adj_cell_int_id = tgt.int_id, 'internal', 'external')
FROM C_ADJACENT_CELL_4G adj
JOIN C_ECELL src
ON src.int_id = adj.src_cell_int_id
LEFT
JOIN C_ECELL tgt
ON tgt.int_id = adj.adj_cell_int_id
LEFT
JOIN C_EXTERNALEUTRANCELLFDD ext
ON ext.int_id = adj.adj_cell_int_id
WHERE src.earfcndl IS NOT NULL
AND ( tgt.earfcndl IS NOT NULL OR ext.earfcndl IS NOT NULL )
(The condition in the WHERE clause guarantees us that we found a matching row in either tgt
or ext
; if there wasn't a matching row in either, then earfcndl
column from both outer joined tables would be NULL.)
We could make use a UNION ALL
set operator, to combine rows from C_ECELL
and C_EXTERNALEUTRANCELLFDD
into a single set, as an inline view, and then join to the combined set:
SELECT ...
FROM C_ADJACENT_CELL_4G adj
JOIN (
SELECT 'i' AS src
, intl.int_id
, intl.earfcndl
FROM C_ECELL int
UNION ALL
SELECT 'e' AS src
, extl.int_id
, extl.earfcndl
FROM C_EXTERNALEUTRANCELLFDD extl
) tgt
ON tgt.int_id = ...
If the same value of int_id
appears in both intl
and extl
, the join operation will match both rows.
But I would avoid the UNION ALL approach. And instead do outer joins to both of the target tables. And then do a check (in an expression in the SELECT list) to determine if we found a match in C_ECELL
. If not, we must have found a match in C_EXTERNALEUTRANCELLFDD
.
Something along these lines:
SELECT adj.int_id AS _adj__int_id
, src.int_id AS _src__int_id
, tgt.int_id AS _tgt__int_id
, ext.int_id AS _ext__int_id
, src.earfcndl AS _src__earfcndl
, tgt.earfcndl AS _tgt__earfcndl
, ext.earfcndl AS _ext__earfcndl
, IF(adj.adj_cell_int_id = tgt.int_id, 'internal', 'external')
FROM C_ADJACENT_CELL_4G adj
JOIN C_ECELL src
ON src.int_id = adj.src_cell_int_id
LEFT
JOIN C_ECELL tgt
ON tgt.int_id = adj.adj_cell_int_id
LEFT
JOIN C_EXTERNALEUTRANCELLFDD ext
ON ext.int_id = adj.adj_cell_int_id
WHERE src.earfcndl IS NOT NULL
AND ( tgt.earfcndl IS NOT NULL OR ext.earfcndl IS NOT NULL )
(The condition in the WHERE clause guarantees us that we found a matching row in either tgt
or ext
; if there wasn't a matching row in either, then earfcndl
column from both outer joined tables would be NULL.)
answered Nov 20 '18 at 21:35
spencer7593spencer7593
84.3k107994
84.3k107994
add a comment |
add a comment |
You need to join with a UNION
of C_ECELL
and C_EXTERNALEUTRANCELLFDD
.
SELECT adj.int_id, if(src.earfcnDl = tgt.earfcnDl, 'ADJS', 'ADJI') AS TYPE
FROM C_ADJACENT_CELL_4G adj
JOIN C_ECELL src ON (src.int_id = adj.src_cell_int_id)
JOIN (
SELECT int_id, earfcnDl
FROM C_ECELL
WHERE earfcndl IS NOT NULL
UNION
SELECT int_id, earfcnDl
FROM C_EXTERNALEUTRANCELLFDD
WHERE earfcndl IS NOT NULL) AS tgt ON (tgt.int_id = adj.adj_cell_int_id)
WHERE src.earfcndl IS NOT NULL
Absolutely perfect. Works a treat and provides exactly what I need. So very grateful. To answer your question about the use of two int_ids in the provided select statement, the second int_id is just a dummy value to replicate a second value I do use in the select statement which I pass into the method that executes the select statement. Most happy
– Fintan O'Halloran
Nov 20 '18 at 22:01
add a comment |
You need to join with a UNION
of C_ECELL
and C_EXTERNALEUTRANCELLFDD
.
SELECT adj.int_id, if(src.earfcnDl = tgt.earfcnDl, 'ADJS', 'ADJI') AS TYPE
FROM C_ADJACENT_CELL_4G adj
JOIN C_ECELL src ON (src.int_id = adj.src_cell_int_id)
JOIN (
SELECT int_id, earfcnDl
FROM C_ECELL
WHERE earfcndl IS NOT NULL
UNION
SELECT int_id, earfcnDl
FROM C_EXTERNALEUTRANCELLFDD
WHERE earfcndl IS NOT NULL) AS tgt ON (tgt.int_id = adj.adj_cell_int_id)
WHERE src.earfcndl IS NOT NULL
Absolutely perfect. Works a treat and provides exactly what I need. So very grateful. To answer your question about the use of two int_ids in the provided select statement, the second int_id is just a dummy value to replicate a second value I do use in the select statement which I pass into the method that executes the select statement. Most happy
– Fintan O'Halloran
Nov 20 '18 at 22:01
add a comment |
You need to join with a UNION
of C_ECELL
and C_EXTERNALEUTRANCELLFDD
.
SELECT adj.int_id, if(src.earfcnDl = tgt.earfcnDl, 'ADJS', 'ADJI') AS TYPE
FROM C_ADJACENT_CELL_4G adj
JOIN C_ECELL src ON (src.int_id = adj.src_cell_int_id)
JOIN (
SELECT int_id, earfcnDl
FROM C_ECELL
WHERE earfcndl IS NOT NULL
UNION
SELECT int_id, earfcnDl
FROM C_EXTERNALEUTRANCELLFDD
WHERE earfcndl IS NOT NULL) AS tgt ON (tgt.int_id = adj.adj_cell_int_id)
WHERE src.earfcndl IS NOT NULL
You need to join with a UNION
of C_ECELL
and C_EXTERNALEUTRANCELLFDD
.
SELECT adj.int_id, if(src.earfcnDl = tgt.earfcnDl, 'ADJS', 'ADJI') AS TYPE
FROM C_ADJACENT_CELL_4G adj
JOIN C_ECELL src ON (src.int_id = adj.src_cell_int_id)
JOIN (
SELECT int_id, earfcnDl
FROM C_ECELL
WHERE earfcndl IS NOT NULL
UNION
SELECT int_id, earfcnDl
FROM C_EXTERNALEUTRANCELLFDD
WHERE earfcndl IS NOT NULL) AS tgt ON (tgt.int_id = adj.adj_cell_int_id)
WHERE src.earfcndl IS NOT NULL
answered Nov 20 '18 at 21:25
BarmarBarmar
422k35244346
422k35244346
Absolutely perfect. Works a treat and provides exactly what I need. So very grateful. To answer your question about the use of two int_ids in the provided select statement, the second int_id is just a dummy value to replicate a second value I do use in the select statement which I pass into the method that executes the select statement. Most happy
– Fintan O'Halloran
Nov 20 '18 at 22:01
add a comment |
Absolutely perfect. Works a treat and provides exactly what I need. So very grateful. To answer your question about the use of two int_ids in the provided select statement, the second int_id is just a dummy value to replicate a second value I do use in the select statement which I pass into the method that executes the select statement. Most happy
– Fintan O'Halloran
Nov 20 '18 at 22:01
Absolutely perfect. Works a treat and provides exactly what I need. So very grateful. To answer your question about the use of two int_ids in the provided select statement, the second int_id is just a dummy value to replicate a second value I do use in the select statement which I pass into the method that executes the select statement. Most happy
– Fintan O'Halloran
Nov 20 '18 at 22:01
Absolutely perfect. Works a treat and provides exactly what I need. So very grateful. To answer your question about the use of two int_ids in the provided select statement, the second int_id is just a dummy value to replicate a second value I do use in the select statement which I pass into the method that executes the select statement. Most happy
– Fintan O'Halloran
Nov 20 '18 at 22:01
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%2f53401498%2fhave-a-select-statement-with-joins-and-unions-and-cant-get-it-to-work%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
Why do you select
INT_ID
twice? And what's the point of theTYPE
column in the subquery?– Barmar
Nov 20 '18 at 21:19
You're using the alias
tgt
twice. You need a different alias forC_EXTERNALEUTRANCELLFDD
– Barmar
Nov 20 '18 at 21:21