assigning mysql value to variable inline
问题 Why doesn't this work i'm trying to get the previous and current value to calculate percent change. I get both values correctly but now how can I reuse them to do the math operatio When I try the below command I get ERROR 1054 (42S22): Unknown column 'currentVal' in 'field list' SELECT IFNULL(DValue,0) as currentVal, (SELECT IFNULL(DValue,0) FROM ... WHERE...) as previousVal, (currentVal-previousVal)/previousVal FROM ... WHERE ...; 回答1: Wrap another query around what you currently have and