When working with MySQL, you can use the CONV() function to convert a number from one base to another. It takes three arguments; the number to convert, the original base, and the base you want to convert it to.
MySQL
How to Get the Number of Bits in a String in MySQL – BIT_LENGTH()
MySQL has a BIT_LENGTH() function that allows you to get the length of a string, measured in bits.
This function is similar to the LENGTH() function, which returns the length of a string in bytes. The same is true for the OCTET_LENGTH() function, which is a synonym for the LENGTH() function.
How to Return the Left or Right Part of a String in MySQL
When working with MySQL databases, you might occasionally find yourself needing to select only a certain number of characters from the left or right of a string. In such cases, you can use the LEFT() and RIGHT() functions to do just that.
Here’s the syntax for both of these functions:
LEFT(str,len) RIGHT(str,len)
Where str is the string that contains the substring you need to return, and len is the number of characters from the left you want returned.
The Easiest Way to Add Multiple Spaces to a String in MySQL – SPACE()
Occasionally when working with MySQL databases, you might find yourself needing to add multiple space characters to a string.
Maybe you need to pad a string by adding leading or trailing spaces. Or maybe you need to replace a single space within the string with many spaces. Either way, MySQL has the SPACE() function to help you.
The SPACE() function is an easy way for you to return as many space characters as you need.
How to Remove Leading and Trailing Characters in MySQL
MySQL has a TRIM() function that enables you to remove leading and/or trailing whitespace from a string.
You can also use it to remove other specified characters from either side (or both sides) of the string.
This article explains how to remove specified leading/trailing characters from the string.