totn MariaDB Functions

MariaDB: LEAST Function

This MariaDB tutorial explains how to use the MariaDB LEAST function with syntax and examples.

Description

The MariaDB LEAST function returns the smallest value in a list of expressions.

Syntax

The syntax for the LEAST function in MariaDB is:

LEAST( expr1, expr2, ... expr_n )

Parameters or Arguments

expr1, expr2, ... expr_n
The expressions that are evaluated by the LEAST function.

Note

  • If the list of expressions are numeric values, the LEAST function will return the smallest numeric value.
  • If the list of expressions are string values, the LEAST function will return the smallest string value.

Applies To

The LEAST function can be used in the following versions of MariaDB:

  • MariaDB 10

Example

Let's look at some MariaDB LEAST function examples and explore how to use the LEAST function in MariaDB.

For example:

SELECT LEAST(8, 9, 10);
Result: 8

SELECT LEAST('8', '9', '10');
Result: '10'

SELECT LEAST('TechOnTheNet.com', 'CheckYourMath.com', 'BigActivities.com');
Result: 'BigActivities.com'

SELECT LEAST('TechOnTheNet.com', 'CheckYourMath.com', NULL);
Result: NULL