SelectSUBSTRING_INDEX('MyNameisRam','a',3);+-------------------------- -------------+|SUBSTRING_INDEX('MyNameisRam',&a"/> SelectSUBSTRING_INDEX('MyNameisRam','a',3);+-------------------------- -------------+|SUBSTRING_INDEX('MyNameisRam',&a">

Home  >  Article  >  Database  >  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
PHPzforward
2023-09-02 14:49:07775browse

如果 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)

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete