Friday, 13 September 2013

Dynamical alias from date in MySQL

Dynamical alias from date in MySQL

i would like to make dynamic alias from dates as you can se below.
Everyday will be the name of column different. I tried it with variable
but it doesn't work. The solution should be something like below or if i
dont need to use variables it can be possible too.
SET @today = CURRENT_DATE(),
@lastWeek = DATE_ADD(CURRENT_DATE(),INTERVAL -7 DAY);
SELECT date1 AS @today, date2 AS @lastweek FROM table1;
Thank you for your help

No comments:

Post a Comment