MySQL RAND Function

Example

Return a random decimal number (no seed value – so it returns a completely random number >= 0 and <1):

SELECT RAND();

Definition and Usage

The RAND() function returns a random number between 0 (inclusive) and 1 (exclusive). Continue reading MySQL RAND Function

MySQL RADIANS Function

Example

Convert a degree value into radians:

SELECT RADIANS(180);

Definition and Usage

The RADIANS() function converts a degree value into radians.

Continue reading MySQL RADIANS Function

MySQL POWER Function

Example

Return 4 raised to the second power:

SELECT POWER(4, 2);

Definition and Usage

The POWER() function returns the value of a number raised to the power of another number.

Continue reading MySQL POWER Function

MySQL POW Function

Example

Return 4 raised to the second power:

SELECT POW(4, 2);

Definition and Usage

The POW() function returns the value of a number raised to the power of another number.

 

Syntax

POW(x, y)

Parameter Values

Parameter Description
x Required. A number (the base)
y Required. A number (the exponent)

Technical Details

Works in: From MySQL 4.0

More Examples

Example

Return 8 raised to the third power:

SELECT POW(8, 3);

MySQL PI Function

Example

Return the value of PI:

SELECT PI();

Definition and Usage

The PI() function returns the value of PI.

Continue reading MySQL PI Function

MySQL MOD Function

Example

Return the remainder of 18/4:

SELECT MOD(18, 4);

Definition and Usage

The MOD() function returns the remainder of a number divided by another number. Continue reading MySQL MOD Function

MySQL MIN Function

Example

Find the price of the cheapest product in the “Products” table:

SELECT MIN(Price) AS SmallestPrice FROM Products;

Definition and Usage

The MIN() function returns the minimum value in a set of values.

Note: See also the MAX() function. Continue reading MySQL MIN Function

MySQL MAX Function

Example

Find the price of the most expensive product in the “Products” table:

SELECT MAX(Price) AS LargestPrice FROM Products;

Definition and Usage

The MAX() function returns the maximum value in a set of values.

Continue reading MySQL MAX Function

MySQL LOG10 Function

Example

Return the base-10 logarithm of 2:

SELECT LOG10(2);

Definition and Usage

The LOG10() function returns the natural logarithm of a number to base-10.

 

Syntax

LOG10(number)

Parameter Values

Parameter Description
number A number greater than 0

Technical Details

Works in: From MySQL 4.0

More Examples

Example

Return the base-10 logarithm of 4.5:

SELECT LOG10(4.5);