There is a special rule in MySQL that column aliases are not allowed as query criteria. For example, there is a table below:
Select
Id
Title
Concept
Conceptlength,
Adduserid,
Modifytime
From Collections_wisdom
Modify the SQL as follows:
Select
Id+1 as NewID,
Title
Concept
Conceptlength,
Adduserid,
Modifytime
From Collections_wisdom
where NewID>2
Then, there will be an exception to execute:statementcallback; bad SQL grammar
Really to execute, had to put the new field composition in the condition to be realized again, as follows:
Select
Id+1 as NewID,
Title
Concept
Conceptlength,
Adduserid,
Modifytime
From Collections_wisdom
where (id+1)>2
A column alias is not allowed in MySQL as a query condition, it is said that the alias of the column in MySQL is originally displayed when the result is returned, not in SQL parsing. Before there is no more convincing explanation, right vote as such.
Column aliases are not allowed in MySQL as query criteria