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
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.