views:

31

answers:

1

Hi Friends,

I have a MySQL table in which i have a time field in INT(10) format. I am storing UnixTime in it. Some of the records have a Zero value and some have a date in it. I want to build a query which shows "No Date" if the value is 0 else show the stored date if there is any date stored in the record on query execution.

The table looks something like this...

ID DATE

1 0
2 0506009

Any Suggestions?

+3  A: 
SELECT IF(date=0, 'No Date', date) FROM table;

(I'd suggest to store NULL instead of 0.)

Lukáš Lalinský
the problem is that the database is too big with thousands of records. Now nothing can be done to replace it with NULL
Ari
@Abhishek: I don't see how a few thousand records has any impact on converting to null: `[UPDATE table SET date = NULL where date = 0;]
Adam Bellaire