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.
mysql
add a comment |
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.
mysql
add a comment |
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.
mysql
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
mysql
edited Nov 7 at 16:28
Shadow
25.3k92742
25.3k92742
asked Nov 7 at 13:38
fire2018
156
156
add a comment |
add a comment |
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)
add a comment |
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)
add a comment |
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)
add a comment |
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)
It's an user defined variable and will display :
0 (-1+1)
1 (0+1)
2 (1+1)
3 (2+1)
...
26 (25+1)
answered Nov 7 at 13:51
Daniel E.
1,8591620
1,8591620
add a comment |
add a comment |
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%2f53190576%2fwhat-does-it-means-select-xi-xi1-as-xc%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