This tutorial explains how to use the MySQL LEAST function with syntax and examples.
The MySQL LEAST function returns the smallest value in a list of expressions.
The syntax for the LEAST function in MySQL is:
LEAST( expr1, expr2, ... expr_n )
The expressions that are evaluated by the LEAST function.
The LEAST function can be used in the following versions of MySQL:
Let's look at some MySQL LEAST function examples and explore how to use the LEAST function in MySQL.
For example:
mysql> SELECT LEAST(2, 5, 12, 3);
Output: 2
mysql> SELECT LEAST('2', '5', '12', '3');
Output: '12'
mysql> SELECT LEAST('AODBA.com', 'mysite.com', 'bing.com');
Output: 'AODBA.com'
mysql> SELECT LEAST('AODBA.com', 'mysite.com', null);
Output: NULL