sql expression

From: Date: Sun, 22 Feb 2004 05:42:53 +0000
Subject: sql expression
Groups: php.general 
Request: Send a blank email to php-general+get-178475@lists.php.net to get a copy of this message
Hi all, I am trying to provide a star sign search so that the user can search for any given star sign eg Gemini and retrieve all the users who belong to that sign. 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. 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) <= 21 Obviously this wont work because anyone born, lets say on the 20th will not fit that criteria. I've tried other methods but I cant seem to figure out the correct syntax. I thought using CONCAT may work eg: SELECT * FROM users WHERE CONCAT(MONTH(user_data.User_DOB),DAYOFMONTH(user_data.User_DOB)) BETWEEN 521 AND 621 but that doesn't seem to work either. Can someone help please? Thanks in advance.

« previous php.general (#178475) next »