Andriy Pasichnyk wrote:
> if i say:
>
> SELECT * FROM people WHERE age='22'
>
> than i'll select andrew and bob only, cuz it's 2005. but in 2006 cynth will turn 22 plus andy and
> bob will be 23.
Well don't use the age column then, but write this instead:
SELECT * FROM people WHERE YEAR(CURDATE()) - YearOfBirth = 22;
This will always work (except for the fact you only have the year and not the full date, as I noted in my first reply.
> so i was curious whether the 'age' value can automaticly be assigned a formula
> "YEAR(CURDATE()) - YearOfBirth" got it?
No, it cannot. The correct way to use computed values is by explicitely using the formula in your queries.
Another way would be to run the following query every 1st January:
UPDATE people SET age = YEAR(CURDATE()) - YearOfBirth;
But personally I prefer the first method.
--
felix
Please use
BBCode to format your messages in this forum.