I\'m trying to select the max date in three different fields in each record (MySQL)
So, in each row, I have date1, date2 and date3: date1 is always filled, date2 and date3 c
SELECT id,
GREATEST(date1,
COALESCE(date2, 0),
COALESCE(date3, 0)) as datemax
FROM mytable
Update: This answer previously used IFNULL which does work, but as Mike Chamberlain pointed out in the comments, COALESCE is actually the preferred method.