vendredi 8 mai 2015

MySQL check case where a date is 0000-00-00 00:00:00?

I have this MySQL query:

SELECT `date_joined`, `date_last_joined` FROM `users` WHERE `name` = "mary"

The date_last_joined column is currently 0000-00-00 00:00:00 for all users. It's then updated to the current date next time they log in.

So my question is, how would I return the date_joined if date_last_joined is 0000-00-00 00:00:00, and date_last_joined if it isn't? Is this possible in a MySQL query?

The reasons for this are that returning 0000-00-00 00:00:00 in a Java prepared MySQL query causes all sorts of issues.

Aucun commentaire:

Enregistrer un commentaire