Calculated field in MySQL
| From: | Morten Twellmann | Date: | Sun, 10 Aug 2003 17:40:38 +0000 |
| Subject: | Calculated field in MySQL | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-29803@lists.php.net to get a copy of this message | ||
Hello,
I got the following error message from MySQL:
---
Query failed.
MySQL said:
Unknown column 'AGE' in 'where clause'
query = SELECT *, (Year(Now()) - Year(BDAY)) +
((DAYOFYEAR(Now())-DAYOFYEAR(BDAY))/365) as AGE FROM Katalog WHERE AGE >= 31
AND AGE <= 50 AND IS_MEM_EXP = 0 AND IS_OPEN = 1 ORDER BY INPUT_DATE DESC
---
Now, obviously the column should exist, since I am creating it in the query,
but I do not seem to be able to find the bug.
If I would have used Access, I would have created a query inside the
database from my table and SELECT from that, but since I am not I have to
find other ways.
What I would like to do the most, would be to create a field in the table,
which would calculate the field inside the database, but it does not seem to
be possible, though it would save me a lot of trouble every time I need that
column in my application.
Could someone either tell me whats wrong with my query or tell me what I
need to do to make such a calculated field.
Much appreciated.
Morten Twellmann