Re: sql expression
| From: | John W. Holmes | Date: | Sun, 22 Feb 2004 05:54:41 +0000 |
| Subject: | Re: sql expression | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-178478@lists.php.net to get a copy of this message | ||
Marc Greenstock wrote:
I have a table with all the star signs, in the table are the fields 'Name','From','To'. Both the 'From' and 'To' are an integer of the relevant dates eg in the 'Gemini' row I have: Gemini, 521, 621 (521 means May 21st, 621 means June 21st). I hope I'm explaining my self ok.You should use a regular date column for your "from" and "to" dates.
Now in the users table I have date of birth stored in the Date format eg; 1979-06-20. Here is my current stab at this. SELECT * FROM users WHERE MONTH(user_data.User_DOB) >= 5 AND DAYOFMONTH(user_data.User_DOB) >= 21 AND MONTH(user_data.User_DOB) <= 6 AND DAYOFMONTH(user_data.User_DOB) <= 21and then you can do something like this: WHERE DAYOFYEAR(user_data.User_DOB) BETWEEN DAYOFYEAR(startable.from) AND DAYOFYEAR(startable.to) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com