MySQL - Calculating a value from two columns in each row, using the result in a WHERE or HAVING clause
- by taber
I have a MySQL db schema like so:
id flags views done
-------------------------------
1 2 20 0
2 66 100 0
3 25 40 0
4 30 60 0
... thousands of rows ...
I want to update all of the rows whose flags / views are = 0.2. First as a test I want to try to SELECT to see how many rows would actually get updated. I tried:
SELECT flags/views AS poncho FROM mytable HAVING poncho 0.2
But this only returns like 2 rows and I know there should be a lot more than that. It seems like it's calculating the poncho value on all rows or something odd. What am I doing wrong?
Thanks!