In this guide, we will explain how to use the MySQL LEAST function with syntax and examples.
Description
The MySQL LEAST function returns the smallest value in a list of expressions.
Syntax
The syntax for the LEAST function is:
LEAST( expr1, expr2, ... expr_n )
Parameters or Arguments
expr1, expr2, … expr_n
The expressions that are evaluated by the LEAST function.
Applies To
The LEAST function can be used in the following versions :
- MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23
Example
Let’s look at some MySQL LEAST function examples and explore how to use the LEAST function.
For example:
mysql> SELECT LEAST(2, 5, 12, 3); Result: 2 mysql> SELECT LEAST('2', '5', '12', '3'); Result: '12' mysql> SELECT LEAST('adglob.in', 'baldevinfo.com', 'baladevainfosystem.com'); Result: 'baladevainfosystem.com' mysql> SELECT LEAST('adglob.in', 'baldevinfo.com', null); Result: NULL
Next Topic : Click Here
Pingback: MySQL: GREATEST Function | Adglob Infosystem Pvt Ltd