In the query below the SELECT statement has an IF case, if the price in table a is equal to 999999 than I set n_price to 0 otherwise the price stays the same.
What I want to know is would there be a simple way of using n_price (the updated value from the query) in the WHERE clause instead of a.price
to carry out a calculation? if not what would be a simple way to retrieve the value in the WHERE clause
SELECT
IF(a.price = 999999, 0, a.price) AS n_price,
l.quantity AS n_quantity,
l.condition AS n_condition
FROM b_products b
LEFT JOIN a_products a ON b.id = a.id
LEFT JOIN l_products l ON b.id = l.id
WHERE
AND ROUND((a.price/100*80) - l.price) >= (l.price/100*30)