![]() The function outputs every character of the source string until the delimiter is matched the number of times given by the occurrence count.Īs you can see, the function returned all the characters until the first space from the left was found. When the count is a positive number, we count from the left. When it is negative, we count the occurrences of the delimiter from the right. Note that the occurrence count can be a negative value. It indicates the number of times the delimiter pattern needs to be matched. The last argument is the occurrence count. Remember that the delimiter is a string, so it must be written in quotes (‘’). This pattern is case sensitive that is, it matters whether the given characters are upper or lower case. The delimiter can be a single character such as a space, but it can also be a pattern that consists of two or more characters. When found, it indicates the place where the substring ends. The delimiter is a string of characters that the SUBSTRING_INDEX() function looks for in the source string. The source string is the string that we would like to split. The function SUBSTRING_INDEX() takes 3 arguments: the source string, the delimiter, and the occurrence count of the delimiter. Here’s the result of the query: firstname SUBSTRING_INDEX(name,' ',1) AS firstname, We’ll use the SUBSTRING_INDEX() function. ![]() ![]() Let’s fetch the data from the column name and split it into firstname and lastname. Our database has a table named Student with data in the columns id and name.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |