Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

CONV

Example

Converts a number from decimal (base 10) to binary (base 2).

SELECT CONV(15102);

Definition and Usage

The CONV() function converts a number from one numeric base system to another and outputs the result as a string.

Note: The CONV() function returns NULL if any of its parameters are NULL.

Tip: Additionally, consider using the BIN() function for specific binary conversions.

Syntax

CONV(numberfrom_baseto_base)

Parameter Values

Parameter

Description

number

Required: A numerical value

from_base

The numeric base system of the number (a value between 2 and 36)

to_base

The numeric base system to convert to (a value between 2 and 36 or -2 and -36)

Technical Details

Works in:

 From MySQL version 4.0

More Examples

Example

Converts a number from binary (base 2) to decimal (base 10).

SELECT CONV(1111210);

Example

Converts a number from decimal (base 10) to hexadecimal (base 16).

SELECT CONV(881016);