I am trying to use a named calculation from one select into another,using Ver 15.1 Distrib 10.1.38-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2.
select f.price * t.price as result_price, result_price-30/30 as percentage from table f join table t on f.to_id = t.from_id where f.from_id = 12 and t.to_id=205;
It gives me an error "ERROR 1054 (42S22): Unknown column 'result_price' in 'field list'". How can I make it see result_price in select statement, or do I just simply make a duplification and write "(t.price*f.price - 30) / 30". Which one is more efficient?
(f.price * t.price) as result_priceand((f.price * t.price)-30/30) as percentageSELECTpart of the query as they will not be evaluated in time. Make the duplication.