Return default timestamp object instead of zero

I have a Timestamp object -

java.sql.Timestamp time = null;

and the value datetime val_timein the DB table.

val_time datetime

The situation is that when the operation is performed, this val_timeone is not updated (which in my case is pretty normal). When reading from the database, the datetime value will naturally be zero. Thus, the timestamp object will also be null. My question is, can we get a default value other than zero?

+5
source share
1 answer

since you indicated in the tags that use mysql, I would recommend that you use the IFNULL statement in your query to get the default value instead of NULL.

SELECT IFNULL(colname, your-default-value) FROM xyz;

http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#function_ifnull

+7

All Articles