Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have written a query to fetch a time internal:

select *, (Time + interval '2012-12-18 13:36:47' minute)  from chatnotiservice;

Is it possible to name the (Time + interval '2012-12-18 13:36:47' minute) column?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

Use AS. For example:

mysql> select 'data' as mycolumnname;
+--------------+
| mycolumnname |
+--------------+
| data         |
+--------------+
1 row in set (0.00 sec)

mysql> 

If you actually want to name the column after the date operation you're performing (your question isn't clear), you can do it by enclosing it in backticks. For example:

mysql> select 'data' as `Time + interval '2012-12-18 13:36:47' minute` ;
+----------------------------------------------+
| Time + interval '2012-12-18 13:36:47' minute |
+----------------------------------------------+
| data                                         |
+----------------------------------------------+
1 row in set (0.00 sec)

mysql>

I suspect what you mean is the following:

select *,(Time + interval '2012-12-18 13:36:47' minute) AS mytime from chatnotiservice;
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.