Hey all,
I am trying to do a calculation in a MySQL query, but am running into trouble when I attempt to use an aliased column name (the values for which are calculated on-the-fly) in the WHERE clause:
'SELECT left_bound, right_bound, (left_bound - right_bound) AS difference FROM numbers WHERE difference < 10 ORDER BY difference ASC LIMIT 5'
yields the error:
Unknown column 'difference' in 'where clause'
I see where the error is coming from, but how would one go about referencing a "virtual" column whose values are calculated on-the-fly?