MySQL: SIGN Function

  • Post author:
  • Post category:MySQL
  • Post comments:1 Comment
MySQL SIGN Function

In this MySQL tutorial explains how to use the MySQL SIGN function with syntax and examples.

Description

The MySQL SIGN function returns a value indicating the sign of a number.

Syntax

The syntax for the SIGN function in MySQL is:

SIGN( number )

Parameters or Arguments

number

The number to test for its sign.

Note

  • The SIGN function returns -1, if the number is less than 0.
  • The SIGN function returns 0, if the number is equal to 0.
  • The SIGN function returns 1, if the number is greater than 0.

Applies To

The SIGN 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 SIGN function examples and explore how to use the SIGN function.

For example:

mysql> SELECT SIGN(12);
Result: 1

mysql> SELECT SIGN(0);
Result: 0

mysql> SELECT SIGN(-12);
Result: -1

Next Topic : Click Here

This Post Has One Comment

Leave a Reply