Re: sql expression

From: Date: Sun, 22 Feb 2004 05:54:02 +0000
Subject: Re: sql expression
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-178477@lists.php.net to get a copy of this message
Ok I spoke too soon, I did this: SELECT * FROM users WHERE ((MONTH(user_data.User_DOB) * 100) + DAYOFMONTH(user_data.User_DOB)) BETWEEN 521 AND 621 as in I multiplied MONTH with 100 and added the DAYOFMONTH Marc. "Marc Greenstock" <marc@shockmedia.com.au> wrote in message news:20040222054256.29470.qmail@pb1.pair.com... > 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 (#178477) next »