Function to return the minimum or maximum value per row with MySQL

MySQL's MIN and MAX functions are for aggregations only. This will not work and produce an error:

SELECT id, MIN(birthday, '1978-01-01') FROM users;

In order to compute the minimum or maximum value for the current row, use LEAST Show archive.org snapshot and GREATEST Show archive.org snapshot instead:

SELECT id, LEAST(birthday, '1978-01-01') FROM users;
Henning Koch