I have a problem with an IF() clause on my query statement. I am simply moving an integer to another column that I dynamically create in my query statement but the integer loses its attribute classification and MySQL treats it as a string.
mysql_query('
SELECT id, statusDate, displayName, earnings,
IF(statusDate <> "0000-00-00 00:00:00", earnings, "0") as earnings1
FROM my_table
ORDER BY statusDate, earnings1 DESC, displayName
');
I have some earnings
in the table such as 10, 50, 200, etc.
Since I am doing a descending order by, I am expecting: 200 50 10
But what I am getting is: 10, 200, 50
Any idea on how I can retain earnings
as an integer, when moving to earnings1
?
Thank you.