How to alias a field or column in MySQL?
select @code:= SUM(field1 + field2), @code+1 from abc; But, please be aware of the following (from the MySQL 5.6 docs): As a general rule, other than in SET statements, you should never assign a value to a user variable and read the value within the same statement. For example, to increment a variable, this is … Read more