From: Michael Dykman Date: August 27 2010 8:56pm Subject: Re: dynamic alias? List-Archive: http://lists.mysql.com/mysql/222714 Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable It would be easiest if you showed us the query you are using but the simple column alias has been in MySQL since v2 SELECT foo, count(*) bar AS mycount FROM... In keeping with SQL practice, the 'AS' keyword is optional but it does make it easier to see the syntax. This is equivalent: SELECT foo, count(*) bar mycount FROM... - michael dykman On Fri, Aug 27, 2010 at 2:59 PM, Eric Bloomquist wrote: > Thanks, PREPARE certainly has some potential. > > Unfortunately, when I try to use that sort of thing inside of a Cognos > report, it complains that "At least one expression in the Select clause > is missing the AS clause to make it a proper alias." > > (Sorry I didn't include the Cognos context -- it didn't occur to me that > it'd be relevant.) > > Thanks, > Eric > > > -----Original Message----- > From: Peter Brawley [mailto:peter.brawley@stripped] > Sent: Friday, August 27, 2010 12:57 PM > To: mysql@stripped > Subject: Re: dynamic alias? > > =A0On 8/27/2010 11:16 AM, Eric Bloomquist wrote: >> Hi all, >> >> I'm wondering if it's possible to have a dynamic alias in MySQL. =A0The >> result I'm looking for is essentially: > See the manual page for PREPARE. > > PB > > ----- >> +-----------------+---------------------------+--------------------+ >> | Provider Name =A0 | Facility Name =A0 =A0 =A0 =A0 =A0 =A0 | Appts on 8= /28/2010 > |<=3D=3D >> +-----------------+---------------------------+--------------------+ >> | Mildred Ratched | Oregon State Hospital =A0 =A0 | =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 12 | >> | Henry Jekyll =A0 =A0| London Internal Medicine =A0| =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A03 | >> | ... =A0 =A0 =A0 =A0 =A0 =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| >> >> Where "Appts on 8/28/2010" instead includes whatever tomorrow's date > is >> when the query is run. >> >> Is it possible to do something like this in a MySQL query? >> >> Thanks, >> Eric >> >> > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: > http://lists.mysql.com/mysql?unsub=3DEric_Bloomquist@stripped > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: =A0 =A0http://lists.mysql.com/mysql?unsub=3Dmdykman@gmail= .com > > --=20 =A0- michael dykman =A0- mdykman@stripped =A0May the Source be with you.