Hi all
I am trying to make searches based on the age of a person. The db contains
only the Date of Birth.
So...
My first attempt was to try the following :
(this is all done in the command line on Win2000)
SELECT firstname, surname, dob, floor((to_days(curdate())-to_days(DOB))/365)
AS age FROM artistes;
This works and returns all the values with the addition of an age column
with what appears to be the correct age.
However...
When I try adding a WHERE clause:
SELECT firstname, surname, dob, floor((to_days(curdate())-to_days(DOB))/365)
AS age FROM artistes WHERE age = "25";
I get ERROR 1054: Unknown column 'age' in 'where clause'
How am I to use this 'virtual' age column in my searches?
I want to be able to search on exact and age ranges plus display the age in
the returned results.
Any ideas/feedback truly welcome, I am 'under the cosh' to get this done
asap!!! (as usual)
TIA
matt
//t h r e e z e r o : : :
the mill, millstone lane, leicester, le1 5jn
e : [EMAIL PROTECTED] :: w : www.threezero.co.uk
t : 0116 225 0662 :: m : 07747 845690
: : : t h r e e z e r o//
> From: Paul Burney <[EMAIL PROTECTED]>
> Date: Wed, 11 Apr 2001 19:07:02 -0700
> To: Mike Baerwolf <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
> Subject: Re: [PHP-DB] select substring_index
>
> on 4/11/01 7:48 PM, Mike Baerwolf at [EMAIL PROTECTED] wrote:
>
>> SELECT substring_index( body, ". ", 2) FROM news;
>>
>> This works great from the mysql client but when I try it using php with
>> this:
>>
>> $result = mysql_query("SELECT substring_index(body, "." ,2) FROM news"
>
> The way you have this written, PHP is using the . for concatenation. To fix
> the problem you need to alternate or escape the quotes, i.e. :
>
> $result = mysql_query("SELECT substring_index(body, \".\" ,2) FROM news"
>
> or
>
> $result = mysql_query('SELECT substring_index(body, "." ,2) FROM news'
>
> or
>
> $result = mysql_query("SELECT substring_index(body, '.' ,2) FROM news"
>
> Hope that helps,
>
> Paul Burney
> http://paulburney.com/
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]