List:General Discussion« Previous MessageNext Message »
From:Daevid Vincent Date:October 23 2007 8:49pm
Subject:Why can't I still not use an ALIAS in the SELECT portion of an SQL statement?
View as plain text  
When will I be able to do something seemingly so basic as this re-use of an
alias?

SELECT DATE_ADD('2007-10-23', INTERVAL user_access_hours HOUR) 
		AS group_duration_date,
	 UNIX_TIMESTAMP(group_duration_date)
		AS group_duration_date_timestamp
FROM 	 end_user_groups;

Error Code : 1054
Unknown column 'group_duration_date' in 'field list'
(0 ms taken)

So instead I must do this very cumbersome and inefficient way:

SELECT DATE_ADD('2007-10-23', INTERVAL user_access_hours HOUR) 
		AS group_duration_date,
	 UNIX_TIMESTAMP(DATE_ADD('2007-10-23', 
					INTERVAL user_access_hours HOUR)) 
		AS group_duration_date_timestamp
FROM 	 end_user_groups;

*sigh*

This has been a cause of frustration since mysql 3.x series. 
Are there any plans to fix this annoyance? If so, in what version?

Currently using: 
mysql  Ver 14.12 Distrib 5.0.41, for pc-linux-gnu (i686)

Thread
Why can't I still not use an ALIAS in the SELECT portion of an SQL statement?Daevid Vincent23 Oct
  • Re: Why can't I still not use an ALIAS in the SELECT portion of anSQL statement?Peter Brawley24 Oct
    • RE: Why can't I still not use an ALIAS in the SELECT portion of an SQL statement?Daevid Vincent24 Oct
      • Re: Why can't I still not use an ALIAS in the SELECT portion of anSQL statement?mysql24 Oct
        • Re: Why can't I still not use an ALIAS in the SELECT portion of anSQL statement?mysql24 Oct