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?

What happens if the value of parameter 'count' in the MySQL SUBSTRING_INDEX() function is greater than the total number of delimiter occurrences?

PHPz
Release: 2023-09-02 14:49:07
forward
856 people have browsed it

如果 MySQL SUBSTRING_INDEX() 函数中的参数“count”的值大于分隔符出现的总数,会发生什么情况?

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template