采用
COALESCE
SELECt id, GREATEST(date1, COALESCE(date2, 0), COALESCE(date3, 0)) as datemax FROM mytable
更新:以前使用的答案
IFNULL确实有效,但是正如Mike Chamberlain在评论中指出的那样,
COALESCE实际上是首选方法。

采用
COALESCE
SELECt id, GREATEST(date1, COALESCE(date2, 0), COALESCE(date3, 0)) as datemax FROM mytable
更新:以前使用的答案
IFNULL确实有效,但是正如Mike Chamberlain在评论中指出的那样,
COALESCE实际上是首选方法。