Following is my query in which i am trying to apply formula on users.i_dob it if the insertion value is not zero else the query should insert zero. Kindly let me know how can i modify the following actual query in order to achieve my functionality thanks,
Actual QUERY:
INSERT IGNORE into age ( i_age)
SELECT DISTINCT FLOOR((TO_DAYS(NOW())- TO_DAYS(FROM_UNIXTIME(users.i_dob))) / 365.25)
FROM users
What I am trying to do with the query:
INSERT IGNORE into z_census ( i_age)
SELECT IF (i_age == 0) i_age else FLOOR((TO_DAYS(NOW())- TO_DAYS(FROM_UNIXTIME(users.i_dob))) / 365.25)
FROM users
http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#function_if