Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

workaround for not being able to use an alias in the Where clause of m

Status
Not open for further replies.

sbbrown9924

Technical User
Mar 7, 2003
80
US
Does anyone have a solution to not being able to use aliases in the Where clause of a query? I'm using a calendar function that uses day, month and year fields. The database I'm using has a simple date field, so I've created aliases for day, month and year. Here's what I want to do:

$query = "SELECT event_id, DATE_FORMAT(date,'%e') AS msg_day, DATE_FORMAT(date,%c) AS msg_month, DATE_FORMAT(date,'%Y') AS msg_year,title FROM events2 WHERE
msg_month='" . $this->month_number . "' AND
msg_year='" . $this->year ."' ORDER BY date";

Any help would be most appreciated. Thanks.
 
Check out this thread, it looks like it might help. thread436-601190

abombss
 
Dear abombss;

Your suggestion to use the EXTRACT function seemed to work. Thanks for your help!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top