CONV(number, from_base, to_base) converts an integer representation between bases 2 and 36 and returns a string.
Run this SELECT query directly in MySQL or phpMyAdmin. It uses fixed inputs so you can verify the result without creating a table.
SELECT CONV('FF', 16, 10) AS decimal_value;| decimal_value |
|---|
| 255 |
CONV(N, from_base, to_base) converts a number between bases. MySQL supports bases from 2 through 36.
SELECT CONV(N, from_base, to_base);
SELECT CONV('B', 16, 2);1011
SELECT CONV(11, 8, 10);9
Octal 11 equals decimal 9 because 1×81 + 1×80 = 9.
SELECT CONV('D', 16, 2);1101
SELECT CONV(10, 10, 16);A
OCT() is equivalent to converting from base 10 to base 8.
SELECT OCT(7); -- Output: 7
SELECT OCT(8); -- Output: 10
SELECT OCT(9); -- Output: 11
SELECT OCT(10); -- Output: 12
The function returns a string. Bases must be in the supported range; sign handling depends on the sign of the base arguments.
Does CONV() return a numeric data type?
No. CONV() returns a string containing the converted representation.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.