SelectSUBSTRING_INDEX('MyNameisRam','a',3);+-------------------------- -------------+|SUBSTRING_INDEX('MyNameisRam',&a"/> SelectSUBSTRING_INDEX('MyNameisRam','a',3);+-------------------------- -------------+|SUBSTRING_INDEX('MyNameisRam',&a">
Home >Database >Mysql Tutorial >What happens if the value of parameter 'count' in the MySQL SUBSTRING_INDEX() function is greater than the total number of delimiter occurrences?
If the value of parameter "count" is greater than the total number of delimiter occurrences, the MySQL SUBSTRING_INDEX() function will return the same string as the output. This can be demonstrated with the following example -
mysql> Select SUBSTRING_INDEX('My Name is Ram','a',3); +-----------------------------------------+ | SUBSTRING_INDEX('My Name is Ram','a',3) | +-----------------------------------------+ | My Name is Ram | +-----------------------------------------+ 1 row in set (0.00 sec)
The above query returns the same string because 3 is greater than the total number of occurrences of the delimiter (i.e. "a") provided as parameter. There are only two "a"s in the string.
The above is the detailed content of What happens if the value of parameter 'count' in the MySQL SUBSTRING_INDEX() function is greater than the total number of delimiter occurrences?. For more information, please follow other related articles on the PHP Chinese website!