I need to select absolutely all users with a validation date. You need to display the date in the format YYYY-MM-DD. Some users have checkdate = 0. For others who have passed the checkdate check is equal to the correct timestamp.

How to make from_unixtime (checkdate) return 0 if checkdate is 0 and the date is in the format YYYY-MM-DD otherwise, Thank you.

ps Make it one request.

    1 answer 1

    select if(checkdate=0,0,from_unixtime(checkdate)) as checkdate 

    unless of course checkdate can really be exactly zero