You can use the MySQL SUBSTRING_INDEX()
function to return everything before or after a certain character (or characters) in a string.
This function allows you to specify the delimiter to use, and you can specify which one (in the event that there’s more than one in the string).
Syntax
Here’s the syntax:
SUBSTRING_INDEX(str,delim,count)
Where str
is the string, delim
is the delimiter (from which you want a substring to the left or right of), and count
specifies which delimiter (in the event there are multiple occurrences of the delimiter in the string).
Note that the delimiter can be a single character or multiple characters.
Continue reading →