Hay, I have a table a products which has a ‘cost_price’ field. When a user sees this field it has been put through a function in PHP which returns a new value (basically adds 20% and then removes a certain percent based on a user’s registration level). Let’s say this function is called ‘final_price()’. This takes and outputs a float.
I want to preform a query like this
SELECT * FROM `products` WHERE `member_price` BETWEEN `x` AND `y`
However the ‘member_price’ field doesn’t exist, this will be the value from the ‘final_price’ function. So the ‘cost_price’ would be run through the ‘final_price’ function and be put into the ‘member_price’ field.
Is there a way to do this?
This can give you an idea of how to make the calculation in sql: