What does it means SELECT @xi:=@xi+1 AS xc?











up vote
0
down vote

favorite












I have been asked to refactor a query that contains a snippet :



SELECT @xi:=@xi+1 AS xc
FROM
(SELECT 1
UNION SELECT 2
UNION SELECT 3) xc1,

(SELECT 1
UNION SELECT 2
UNION SELECT 3)xc2,

(SELECT 1
UNION SELECT 2
UNION SELECT 3) xc3,

(SELECT @xi:=-1) xc0


I believe the rest of the query is written in MySQL.



I am completely new to this style of writing queries, and have not come across it in any Postgresql, MySQL or BigQuery Standard SQL documentation.



Unfortunately there are other elements of the query that are not working so I cannot produce an output or describe what I'm trying to achieve (because I have no idea what this does) but thought while I work on those other parts someone might be able to provide some insight to the syntax to this particular piece of logic or maybe provide a topic that I can find out more about this snippet so that I can develop my knowledge.










share|improve this question




























    up vote
    0
    down vote

    favorite












    I have been asked to refactor a query that contains a snippet :



    SELECT @xi:=@xi+1 AS xc
    FROM
    (SELECT 1
    UNION SELECT 2
    UNION SELECT 3) xc1,

    (SELECT 1
    UNION SELECT 2
    UNION SELECT 3)xc2,

    (SELECT 1
    UNION SELECT 2
    UNION SELECT 3) xc3,

    (SELECT @xi:=-1) xc0


    I believe the rest of the query is written in MySQL.



    I am completely new to this style of writing queries, and have not come across it in any Postgresql, MySQL or BigQuery Standard SQL documentation.



    Unfortunately there are other elements of the query that are not working so I cannot produce an output or describe what I'm trying to achieve (because I have no idea what this does) but thought while I work on those other parts someone might be able to provide some insight to the syntax to this particular piece of logic or maybe provide a topic that I can find out more about this snippet so that I can develop my knowledge.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have been asked to refactor a query that contains a snippet :



      SELECT @xi:=@xi+1 AS xc
      FROM
      (SELECT 1
      UNION SELECT 2
      UNION SELECT 3) xc1,

      (SELECT 1
      UNION SELECT 2
      UNION SELECT 3)xc2,

      (SELECT 1
      UNION SELECT 2
      UNION SELECT 3) xc3,

      (SELECT @xi:=-1) xc0


      I believe the rest of the query is written in MySQL.



      I am completely new to this style of writing queries, and have not come across it in any Postgresql, MySQL or BigQuery Standard SQL documentation.



      Unfortunately there are other elements of the query that are not working so I cannot produce an output or describe what I'm trying to achieve (because I have no idea what this does) but thought while I work on those other parts someone might be able to provide some insight to the syntax to this particular piece of logic or maybe provide a topic that I can find out more about this snippet so that I can develop my knowledge.










      share|improve this question















      I have been asked to refactor a query that contains a snippet :



      SELECT @xi:=@xi+1 AS xc
      FROM
      (SELECT 1
      UNION SELECT 2
      UNION SELECT 3) xc1,

      (SELECT 1
      UNION SELECT 2
      UNION SELECT 3)xc2,

      (SELECT 1
      UNION SELECT 2
      UNION SELECT 3) xc3,

      (SELECT @xi:=-1) xc0


      I believe the rest of the query is written in MySQL.



      I am completely new to this style of writing queries, and have not come across it in any Postgresql, MySQL or BigQuery Standard SQL documentation.



      Unfortunately there are other elements of the query that are not working so I cannot produce an output or describe what I'm trying to achieve (because I have no idea what this does) but thought while I work on those other parts someone might be able to provide some insight to the syntax to this particular piece of logic or maybe provide a topic that I can find out more about this snippet so that I can develop my knowledge.







      mysql






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 7 at 16:28









      Shadow

      25.3k92742




      25.3k92742










      asked Nov 7 at 13:38









      fire2018

      156




      156
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          It's an user defined variable and will display :



              0 (-1+1)
          1 (0+1)
          2 (1+1)
          3 (2+1)
          ...
          26 (25+1)





          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',
            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%2f53190576%2fwhat-does-it-means-select-xi-xi1-as-xc%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








            up vote
            2
            down vote



            accepted










            It's an user defined variable and will display :



                0 (-1+1)
            1 (0+1)
            2 (1+1)
            3 (2+1)
            ...
            26 (25+1)





            share|improve this answer

























              up vote
              2
              down vote



              accepted










              It's an user defined variable and will display :



                  0 (-1+1)
              1 (0+1)
              2 (1+1)
              3 (2+1)
              ...
              26 (25+1)





              share|improve this answer























                up vote
                2
                down vote



                accepted







                up vote
                2
                down vote



                accepted






                It's an user defined variable and will display :



                    0 (-1+1)
                1 (0+1)
                2 (1+1)
                3 (2+1)
                ...
                26 (25+1)





                share|improve this answer












                It's an user defined variable and will display :



                    0 (-1+1)
                1 (0+1)
                2 (1+1)
                3 (2+1)
                ...
                26 (25+1)






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 7 at 13:51









                Daniel E.

                1,8591620




                1,8591620






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53190576%2fwhat-does-it-means-select-xi-xi1-as-xc%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







                    這個網誌中的熱門文章

                    Tangent Lines Diagram Along Smooth Curve

                    Yusuf al-Mu'taman ibn Hud

                    Zucchini