SQL - Union select issue, results are not described properly












-1















enter image description here



My Union Select statement works, but the results are on top of each other.



SQL Statement:



SELECT Cust_ID, Cust_FirstName, Cust_LastName 

FROM kmsrutge_xoxoxo.Customers

UNION

SELECT Item_Type, Quantity, Total_Amount

FROM kmsrutge_xoxoxo.Invoices

WHERE Total_Amount >= '$5.00'









share|improve this question




















  • 1





    What are you mixing column data types which are not the same? I don't see any clean way to alter your query to make the result sensible.

    – Tim Biegeleisen
    Nov 6 '18 at 14:02






  • 3





    What is the question?

    – Caleth
    Nov 6 '18 at 14:02











  • I need the bottom column data to the right with the table names.

    – katelynn767
    Nov 6 '18 at 14:32











  • "I need the bottom column data to the right with the table names" I have a feeling you want a pivoting query stackoverflow.com/questions/7674786/mysql-pivot-table ... but hard to say for sure without example data and expected output.. i advice you to read this "Why should I provide an MCVE for what seems to me to be a very simple SQL query?" meta.stackoverflow.com/questions/333952/…

    – Raymond Nijland
    Nov 6 '18 at 14:45













  • From the title of your question: "results are not described properly". The query is returning exactly what you're telling it to. If you need different results, you'll have to change your query accordingly. As others have said, we can help you only if you provide the minimum necessary information. Also, please clarify the Total_Amount field of your Invoices table: Is this a VARCHAR field? If you're storing price information, this needs to be a DECIMAL-type field.

    – Zack
    Nov 6 '18 at 16:11
















-1















enter image description here



My Union Select statement works, but the results are on top of each other.



SQL Statement:



SELECT Cust_ID, Cust_FirstName, Cust_LastName 

FROM kmsrutge_xoxoxo.Customers

UNION

SELECT Item_Type, Quantity, Total_Amount

FROM kmsrutge_xoxoxo.Invoices

WHERE Total_Amount >= '$5.00'









share|improve this question




















  • 1





    What are you mixing column data types which are not the same? I don't see any clean way to alter your query to make the result sensible.

    – Tim Biegeleisen
    Nov 6 '18 at 14:02






  • 3





    What is the question?

    – Caleth
    Nov 6 '18 at 14:02











  • I need the bottom column data to the right with the table names.

    – katelynn767
    Nov 6 '18 at 14:32











  • "I need the bottom column data to the right with the table names" I have a feeling you want a pivoting query stackoverflow.com/questions/7674786/mysql-pivot-table ... but hard to say for sure without example data and expected output.. i advice you to read this "Why should I provide an MCVE for what seems to me to be a very simple SQL query?" meta.stackoverflow.com/questions/333952/…

    – Raymond Nijland
    Nov 6 '18 at 14:45













  • From the title of your question: "results are not described properly". The query is returning exactly what you're telling it to. If you need different results, you'll have to change your query accordingly. As others have said, we can help you only if you provide the minimum necessary information. Also, please clarify the Total_Amount field of your Invoices table: Is this a VARCHAR field? If you're storing price information, this needs to be a DECIMAL-type field.

    – Zack
    Nov 6 '18 at 16:11














-1












-1








-1








enter image description here



My Union Select statement works, but the results are on top of each other.



SQL Statement:



SELECT Cust_ID, Cust_FirstName, Cust_LastName 

FROM kmsrutge_xoxoxo.Customers

UNION

SELECT Item_Type, Quantity, Total_Amount

FROM kmsrutge_xoxoxo.Invoices

WHERE Total_Amount >= '$5.00'









share|improve this question
















enter image description here



My Union Select statement works, but the results are on top of each other.



SQL Statement:



SELECT Cust_ID, Cust_FirstName, Cust_LastName 

FROM kmsrutge_xoxoxo.Customers

UNION

SELECT Item_Type, Quantity, Total_Amount

FROM kmsrutge_xoxoxo.Invoices

WHERE Total_Amount >= '$5.00'






mysql sql union






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 14:59









Al Fahad

725821




725821










asked Nov 6 '18 at 13:58









katelynn767katelynn767

112




112








  • 1





    What are you mixing column data types which are not the same? I don't see any clean way to alter your query to make the result sensible.

    – Tim Biegeleisen
    Nov 6 '18 at 14:02






  • 3





    What is the question?

    – Caleth
    Nov 6 '18 at 14:02











  • I need the bottom column data to the right with the table names.

    – katelynn767
    Nov 6 '18 at 14:32











  • "I need the bottom column data to the right with the table names" I have a feeling you want a pivoting query stackoverflow.com/questions/7674786/mysql-pivot-table ... but hard to say for sure without example data and expected output.. i advice you to read this "Why should I provide an MCVE for what seems to me to be a very simple SQL query?" meta.stackoverflow.com/questions/333952/…

    – Raymond Nijland
    Nov 6 '18 at 14:45













  • From the title of your question: "results are not described properly". The query is returning exactly what you're telling it to. If you need different results, you'll have to change your query accordingly. As others have said, we can help you only if you provide the minimum necessary information. Also, please clarify the Total_Amount field of your Invoices table: Is this a VARCHAR field? If you're storing price information, this needs to be a DECIMAL-type field.

    – Zack
    Nov 6 '18 at 16:11














  • 1





    What are you mixing column data types which are not the same? I don't see any clean way to alter your query to make the result sensible.

    – Tim Biegeleisen
    Nov 6 '18 at 14:02






  • 3





    What is the question?

    – Caleth
    Nov 6 '18 at 14:02











  • I need the bottom column data to the right with the table names.

    – katelynn767
    Nov 6 '18 at 14:32











  • "I need the bottom column data to the right with the table names" I have a feeling you want a pivoting query stackoverflow.com/questions/7674786/mysql-pivot-table ... but hard to say for sure without example data and expected output.. i advice you to read this "Why should I provide an MCVE for what seems to me to be a very simple SQL query?" meta.stackoverflow.com/questions/333952/…

    – Raymond Nijland
    Nov 6 '18 at 14:45













  • From the title of your question: "results are not described properly". The query is returning exactly what you're telling it to. If you need different results, you'll have to change your query accordingly. As others have said, we can help you only if you provide the minimum necessary information. Also, please clarify the Total_Amount field of your Invoices table: Is this a VARCHAR field? If you're storing price information, this needs to be a DECIMAL-type field.

    – Zack
    Nov 6 '18 at 16:11








1




1





What are you mixing column data types which are not the same? I don't see any clean way to alter your query to make the result sensible.

– Tim Biegeleisen
Nov 6 '18 at 14:02





What are you mixing column data types which are not the same? I don't see any clean way to alter your query to make the result sensible.

– Tim Biegeleisen
Nov 6 '18 at 14:02




3




3





What is the question?

– Caleth
Nov 6 '18 at 14:02





What is the question?

– Caleth
Nov 6 '18 at 14:02













I need the bottom column data to the right with the table names.

– katelynn767
Nov 6 '18 at 14:32





I need the bottom column data to the right with the table names.

– katelynn767
Nov 6 '18 at 14:32













"I need the bottom column data to the right with the table names" I have a feeling you want a pivoting query stackoverflow.com/questions/7674786/mysql-pivot-table ... but hard to say for sure without example data and expected output.. i advice you to read this "Why should I provide an MCVE for what seems to me to be a very simple SQL query?" meta.stackoverflow.com/questions/333952/…

– Raymond Nijland
Nov 6 '18 at 14:45







"I need the bottom column data to the right with the table names" I have a feeling you want a pivoting query stackoverflow.com/questions/7674786/mysql-pivot-table ... but hard to say for sure without example data and expected output.. i advice you to read this "Why should I provide an MCVE for what seems to me to be a very simple SQL query?" meta.stackoverflow.com/questions/333952/…

– Raymond Nijland
Nov 6 '18 at 14:45















From the title of your question: "results are not described properly". The query is returning exactly what you're telling it to. If you need different results, you'll have to change your query accordingly. As others have said, we can help you only if you provide the minimum necessary information. Also, please clarify the Total_Amount field of your Invoices table: Is this a VARCHAR field? If you're storing price information, this needs to be a DECIMAL-type field.

– Zack
Nov 6 '18 at 16:11





From the title of your question: "results are not described properly". The query is returning exactly what you're telling it to. If you need different results, you'll have to change your query accordingly. As others have said, we can help you only if you provide the minimum necessary information. Also, please clarify the Total_Amount field of your Invoices table: Is this a VARCHAR field? If you're storing price information, this needs to be a DECIMAL-type field.

– Zack
Nov 6 '18 at 16:11












1 Answer
1






active

oldest

votes


















0














You should pick (select) at least one column that is the same of both tables, and make a join statement per that column in order to get desired result.






share|improve this answer























    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%2f53173394%2fsql-union-select-issue-results-are-not-described-properly%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









    0














    You should pick (select) at least one column that is the same of both tables, and make a join statement per that column in order to get desired result.






    share|improve this answer




























      0














      You should pick (select) at least one column that is the same of both tables, and make a join statement per that column in order to get desired result.






      share|improve this answer


























        0












        0








        0







        You should pick (select) at least one column that is the same of both tables, and make a join statement per that column in order to get desired result.






        share|improve this answer













        You should pick (select) at least one column that is the same of both tables, and make a join statement per that column in order to get desired result.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 6 '18 at 14:07









        Andrija_GrozdanovicAndrija_Grozdanovic

        33




        33
































            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%2f53173394%2fsql-union-select-issue-results-are-not-described-properly%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

            Florida Star v. B. J. F.

            Danny Elfman

            Lugert, Oklahoma