MariaDB SIGN() Function
In MariaDB, SIGN() is a built-in function that returns -1, 0, or 1 to indicate whether the given number is negative, zero, or positive.
MariaDB SIGN() Syntax
Here is the syntax of the MariaDB SIGN() function:
SIGN(number)
Parameters
number-
Required. A number.
If you provide the wrong number of parameters, MariaDB will report an error: ERROR 1582 (42000): Incorrect parameter count in the call to native function 'SIGN'.
Return value
The MariaDB SIGN() function specify the sign of numbers. It returns a value that is one of 1, -1, 0, and NULL:
If number is greater than 0, the SIGN() function will return 1.
If number equals 0, the SIGN() function will return 0.
If number is less than 0, the SIGN() function will return -1.
If number yes NULL, the SIGN() function will return NULL.
MariaDB SIGN() Examples
This statement shows the basic usage of the MariaDB SIGN() function:
SELECT
SIGN(123),
SIGN(123.123),
SIGN(-123),
SIGN(-123.123),
SIGN(0),
SIGN(NULL)\G
Output:
SIGN(123): 1
SIGN(123.123): 1
SIGN(-123): -1
SIGN(-123.123): -1
SIGN(0): 0
SIGN(NULL): NULLConclusion
In MariaDB, SIGN() is a built-in function that returns -1, 0, or 1 to indicate whether the given number is negative, zero, or positive.