Thread: MySQL fields dependance
Results 1 to 4 of 4
Related
-
Replies: 1
-
Populate fields by javascript using MYSQL Forum: Javascript Forum
Replies: 0 -
The sum of two fields Forum: Website Scripts Forum
Replies: 4 -
The sum of two fields Forum: HTML Forum
Replies: 1
-
05-30-2005, 11:40 AM #1
MySQL fields dependance
hey there!
if i have mysql table fields called 'YearOfBirth' and 'Age'. how can i make 'Age' be counted automaticly by subtracting 'YearOfBirth' from 'CurrentYear'?
unfortunately, when i failed to figure that out. besides, it's really uncomfortabe to enter both age and yearofbirth manually plus age expires in a while 8-)
thanks for your help in advance
best regards
-
05-30-2005, 12:47 PM #2
Re: MySQL fields dependance
try somthing like this:
Code:$age = date("Y") - $yearofbirth;
Code:$age = date("Y") - $yearofbirth; if($monthofbirth < date("M")){ if($dayofbirth < date("M")){ $age = $age - 1 } }
-
05-30-2005, 01:06 PM #3
Re: MySQL fields dependance
emmm... thanx anyway, but that's not exactly what i've been looking for.
i mean, when i setup the mysql database using phpmyadmin of course, i create some table fields like 'a' , 'b' and 'c'. i want 'b' have value ('c' - 'a'). i'm looking for mysql function or command whatever can make 'b' a subtraction of 'a' out of 'c'.
i'm interested in doing that and forgetting about the 'b' field. afterwards i will only in enter 'a' and 'c' fields. plus 'b' will always contain correct information.
i've picked example with birth year and age because that's the key thing of my question - i wonder whether mysql has a possibility to generate field values "on-fly"??? if yes, than HOW ON EARTH???
-
05-31-2005, 04:44 AM #4
Re: MySQL fields dependance
You should have a read over this, http://www.keithjbrown.co.uk/vworks/mysql/mysql_p9.shtml , its the mySQL page on generating column values on the fly.
Be aware, it doesn't actaully keep a column in the database updated, but it does return a column value. But that sounds like what you want anyway.
Theres a lot in there, numeric functions are about 2/3rds of the way in. Have a good readIf one of our members helps you, please click theicon to add to their reputation!
No support via email or private message - use the forums!
Before you ask, have you Searched?
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum