THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL SIGN() Function

❮ MySQL Functions

Example

Return the sign of a number:

SELECT SIGN(255.5);
Try it Yourself »

Definition and Usage

The SIGN() function returns the sign of a number.

This function will return one of the following:

  • If number is greater than zero, it returns 1
  • If number is equal to zero, it returns 0
  • If number is less than zero, it returns -1

Syntax

SIGN(number)

Parameter Values

Parameter Description
number Required. The number to return the sign for

Technical Details

Works in: MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

More Examples

Example

Return the sign of a number:

SELECT SIGN(-12);
Try it Yourself »

❮ MySQL Functions