MySQL: ternary IF(expr, if, else) with CAST -
why does
select if(mytimestamp null, null, mytimestamp) fixed_date
return null (as expected), but
select if(mytimestamp null, null, cast(mytimestamp char)) fixed_date
returns '0000-00-00 00:00:00'?
i need latter 1 returning me null, that's why i'm asking. how do that?
edit: mytimestamp timestamp. have expected both statements return null, if mytimestamp = null. in case, timestamp must converted char, because frontend expects way (it's little more complicated, actually).
solution: had set 'mytimestamp' not nullable (and defaultint '0000-00-00...'. setting nullable, works expected (returning null). sorry, fault.
thanks, bernhard
Comments
Post a Comment