What's with error 1241 Operand should contain 1 column?










-1















I have a class project and I want to rank my data according to their score
but every time I run this query on mysql it always gives me error 1241.



Any thoughts on what's causing these?



here is my query:



SELECT
(SELECT gen_cityname,
SUM(scc_bgyscoretotal) as score,
@curRank := @curRank + 1 AS rank
FROM bgyprofile b, (SELECT @curRank := 0) r
WHERE gen_provname = bgyprofile.gen_provname
GROUP BY gen_incomeyr, gen_cityname
ORDER BY score asc) AS provranks
FROM bgyprofile
GROUP BY bgyprofile.gen_incomeyr, bgyprofile.gen_cityname









share|improve this question
























  • I'm trying to rank the score column

    – Yuuki
    Nov 16 '18 at 8:01











  • please provide some sample data for all the relevant tables and expected output. It would be best if you could setup db-fiddle.com

    – Madhur Bhaiya
    Nov 16 '18 at 8:02











  • Subquery in SELECT can only return a scalar value. Your subquery returns a table. Google some subquery tutorial.

    – Eric
    Nov 27 '18 at 17:52















-1















I have a class project and I want to rank my data according to their score
but every time I run this query on mysql it always gives me error 1241.



Any thoughts on what's causing these?



here is my query:



SELECT
(SELECT gen_cityname,
SUM(scc_bgyscoretotal) as score,
@curRank := @curRank + 1 AS rank
FROM bgyprofile b, (SELECT @curRank := 0) r
WHERE gen_provname = bgyprofile.gen_provname
GROUP BY gen_incomeyr, gen_cityname
ORDER BY score asc) AS provranks
FROM bgyprofile
GROUP BY bgyprofile.gen_incomeyr, bgyprofile.gen_cityname









share|improve this question
























  • I'm trying to rank the score column

    – Yuuki
    Nov 16 '18 at 8:01











  • please provide some sample data for all the relevant tables and expected output. It would be best if you could setup db-fiddle.com

    – Madhur Bhaiya
    Nov 16 '18 at 8:02











  • Subquery in SELECT can only return a scalar value. Your subquery returns a table. Google some subquery tutorial.

    – Eric
    Nov 27 '18 at 17:52













-1












-1








-1








I have a class project and I want to rank my data according to their score
but every time I run this query on mysql it always gives me error 1241.



Any thoughts on what's causing these?



here is my query:



SELECT
(SELECT gen_cityname,
SUM(scc_bgyscoretotal) as score,
@curRank := @curRank + 1 AS rank
FROM bgyprofile b, (SELECT @curRank := 0) r
WHERE gen_provname = bgyprofile.gen_provname
GROUP BY gen_incomeyr, gen_cityname
ORDER BY score asc) AS provranks
FROM bgyprofile
GROUP BY bgyprofile.gen_incomeyr, bgyprofile.gen_cityname









share|improve this question
















I have a class project and I want to rank my data according to their score
but every time I run this query on mysql it always gives me error 1241.



Any thoughts on what's causing these?



here is my query:



SELECT
(SELECT gen_cityname,
SUM(scc_bgyscoretotal) as score,
@curRank := @curRank + 1 AS rank
FROM bgyprofile b, (SELECT @curRank := 0) r
WHERE gen_provname = bgyprofile.gen_provname
GROUP BY gen_incomeyr, gen_cityname
ORDER BY score asc) AS provranks
FROM bgyprofile
GROUP BY bgyprofile.gen_incomeyr, bgyprofile.gen_cityname






mysql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 7:57









Madhur Bhaiya

19.6k62336




19.6k62336










asked Nov 16 '18 at 7:56









YuukiYuuki

145




145












  • I'm trying to rank the score column

    – Yuuki
    Nov 16 '18 at 8:01











  • please provide some sample data for all the relevant tables and expected output. It would be best if you could setup db-fiddle.com

    – Madhur Bhaiya
    Nov 16 '18 at 8:02











  • Subquery in SELECT can only return a scalar value. Your subquery returns a table. Google some subquery tutorial.

    – Eric
    Nov 27 '18 at 17:52

















  • I'm trying to rank the score column

    – Yuuki
    Nov 16 '18 at 8:01











  • please provide some sample data for all the relevant tables and expected output. It would be best if you could setup db-fiddle.com

    – Madhur Bhaiya
    Nov 16 '18 at 8:02











  • Subquery in SELECT can only return a scalar value. Your subquery returns a table. Google some subquery tutorial.

    – Eric
    Nov 27 '18 at 17:52
















I'm trying to rank the score column

– Yuuki
Nov 16 '18 at 8:01





I'm trying to rank the score column

– Yuuki
Nov 16 '18 at 8:01













please provide some sample data for all the relevant tables and expected output. It would be best if you could setup db-fiddle.com

– Madhur Bhaiya
Nov 16 '18 at 8:02





please provide some sample data for all the relevant tables and expected output. It would be best if you could setup db-fiddle.com

– Madhur Bhaiya
Nov 16 '18 at 8:02













Subquery in SELECT can only return a scalar value. Your subquery returns a table. Google some subquery tutorial.

– Eric
Nov 27 '18 at 17:52





Subquery in SELECT can only return a scalar value. Your subquery returns a table. Google some subquery tutorial.

– Eric
Nov 27 '18 at 17:52












1 Answer
1






active

oldest

votes


















0














it gives error 1241 because your query has the form



SELECT (SELECT column1, column2 FROM t2) FROM t1;


(https://dev.mysql.com/doc/refman/8.0/en/subquery-errors.html)



As they say in comments sample data and an explenation of what you expect would be very useful. Maybe the first step is to change the query starting with SELECT * and moving the SELECT between brackets after the FROM, but, I repeat, I need some more information to understand the right way.






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%2f53333613%2fwhats-with-error-1241-operand-should-contain-1-column%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














    it gives error 1241 because your query has the form



    SELECT (SELECT column1, column2 FROM t2) FROM t1;


    (https://dev.mysql.com/doc/refman/8.0/en/subquery-errors.html)



    As they say in comments sample data and an explenation of what you expect would be very useful. Maybe the first step is to change the query starting with SELECT * and moving the SELECT between brackets after the FROM, but, I repeat, I need some more information to understand the right way.






    share|improve this answer





























      0














      it gives error 1241 because your query has the form



      SELECT (SELECT column1, column2 FROM t2) FROM t1;


      (https://dev.mysql.com/doc/refman/8.0/en/subquery-errors.html)



      As they say in comments sample data and an explenation of what you expect would be very useful. Maybe the first step is to change the query starting with SELECT * and moving the SELECT between brackets after the FROM, but, I repeat, I need some more information to understand the right way.






      share|improve this answer



























        0












        0








        0







        it gives error 1241 because your query has the form



        SELECT (SELECT column1, column2 FROM t2) FROM t1;


        (https://dev.mysql.com/doc/refman/8.0/en/subquery-errors.html)



        As they say in comments sample data and an explenation of what you expect would be very useful. Maybe the first step is to change the query starting with SELECT * and moving the SELECT between brackets after the FROM, but, I repeat, I need some more information to understand the right way.






        share|improve this answer















        it gives error 1241 because your query has the form



        SELECT (SELECT column1, column2 FROM t2) FROM t1;


        (https://dev.mysql.com/doc/refman/8.0/en/subquery-errors.html)



        As they say in comments sample data and an explenation of what you expect would be very useful. Maybe the first step is to change the query starting with SELECT * and moving the SELECT between brackets after the FROM, but, I repeat, I need some more information to understand the right way.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 29 '18 at 20:54

























        answered Nov 27 '18 at 17:48









        GufusGufus

        138119




        138119





























            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%2f53333613%2fwhats-with-error-1241-operand-should-contain-1-column%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

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            ReactJS Fetched API data displays live - need Data displayed static

            Evgeni Malkin