From the course: MySQL Essential Training

Unlock this course with a free trial

Join today to access over 23,700 courses taught by industry experts.

Numeric conversions

Numeric conversions

- Hi, I'm Bill Weinman. Numeric values are normally expressed in decimal base 10. If you want to express values in other systems, you may convert the number using one of these functions. Let's start with a base 10 number, and I'll say SELECT 32742. And when I execute this, I need to expand the column a little bit. And you see we get the result we expect. Now, if we want to display that in hexadecimal, we can use the HEX converting function. And there we have it in hex, 7FE6. Likewise, we can convert it to octal, 77746. Octal is base 8. Or binary, which is of course base 2. And we get that result in binary. There's also a conversion function that will convert between different bases more arbitrarily. So if I say CONV comma 10 to 16, this will convert our 32742 from base 10 into base 16, which would otherwise be done with the HEX function. But if we wanted to use a different, more unusual base, say base 24, well, we can do that too. And we get 28K6. And likewise, if we wanted to convert…

Contents