When MySQL SUBSTRING_INDEX() function returns the same string, provided in the argument, as output?


MySQL SUBSTRING_INDEX() function will return the same string as output if the argument ‘count’ has the value greater than the total number of occurrences of delimiter. It can be demonstrated with the following example −

mysql> Select SUBSTRING_INDEX('www.google.co.in','.',4);
+-------------------------------------------+
| SUBSTRING_INDEX('www.google.co.in','.',4) |
+-------------------------------------------+
| www.google.co.in                          |
+-------------------------------------------+
1 row in set (0.00 sec)

The above query returns the same string because 4 is greater than the total number of occurrences of delimiter provided as argument i.e. ‘.’.

Lakshmi Srinivas
Lakshmi Srinivas

Programmer / Analyst / Technician

Updated on: 20-Jun-2020

105 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements