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.

Read more

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.

Read more