I have a users table which has a birthdate field. I'm trying to figure out the syntax that would allow me to loop through the table and update another field name current_age. Using somekind of calculation based of the birthdate field.
I was thinking something like
UPDATE users
SET current_age=(birth_date)/(60*60*24*365.2421896)
in some kid of a loop if I need a loop.
UPDATE users table with a calculated field for current_age
Moderator: General Moderators
Re: UPDATE users table with a calculated field for current_a
Don't store the age. It's pointless: you'd have to keep recalculating it every day.
If you need the age then do it in your code. It'll always be correct without you having to repeatedly update some age field.
If you need the age then do it in your code. It'll always be correct without you having to repeatedly update some age field.