Home > database >  The select (3, 3) a, (1) a b; Just finished calculation of variable can use?
The select (3, 3) a, (1) a b; Just finished calculation of variable can use?

Time:10-23

Excuse me, can simple to achieve such a statement?
Select (3 + 3). A, b (a + 1);

CodePudding user response:

 select @ v:=(3 + 3) a, b (@ v + 1); 

CodePudding user response:

The finish is a syntax error

Correct writing:

Select (3 + 3). A, b (' a '+ 1);

Results:
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
A | b
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
6 | 1

CodePudding user response:

You say that also can't use,

CodePudding user response:

With TMP as
(select 3 + 3 as the from a dual)
Select a, a + 1 as b from TMP.

CodePudding user response:

A is variable, like this,
SELECT (3 + 3) a, a + 1) b (@.

It is a field name,
SELECT (3 + 3), a (a + 1) b table_name;

CodePudding user response:

The set @ a=3 + 3;
The set @ b=@ a + 1;

Select @ a, @ b;

CodePudding user response:

/* mysql @ inside a for what? Variable, the second field can't capture ah */
reference 5 floor AHUA1001 reply:
is a variable, so write,
SELECT (3 + 3) a, a + 1) b (@.

It is a field name,
SELECT (3 + 3), a (a + 1) b table_name;

CodePudding user response:

refer to 7th floor stelf response:
/* mysql @ inside a for what? Variable, the second field can't capture ah */
Quote: refer to the fifth floor AHUA1001 reply:

A is variable, like this,
SELECT (3 + 3) a, a + 1) b (@.

It is a field name,
SELECT (3 + 3), a (a + 1) b table_name;


@ a is variable,
Can give the variable assignment, the code is as follows:

The set @ a:=25;
SELECT (3 + 3) a, a + 1) b (@.

These two lines can be executed directly,

CodePudding user response:

Select @ a:=3 + 3 as a, @ : b=(@ a + 1) as b;

The results
A, b
6, 7