Bug #33883 Function to return nth part of a string
Submitted: 16 Jan 2008 8:52 Modified: 16 Jan 2008 10:58
Reporter: Sergei Kulakov (Candidate Quality Contributor) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any
Tags: qc

[16 Jan 2008 8:52] Sergei Kulakov
Description:
substring_index() returns the part of a string from the beginning to nth delimiter of from nth delimiter to the end, but sometimes it is needed to get just a nth part of a string, using a delimiter. For ex., when dealing with IPs, it would be convenient to extract any of the 4 parts of them using a call like 

substring_part(IP, N, '.')

where N=1..4

How to repeat:
Of course, the same can be done with substring_index() called twice and sometimes locate() but that is more complicated and inconvenient. Getting a part of a string is not the only task - one may need to know its length or add it to a longer expression, and having to deal with more complicated formulas to just get a part of a string and then to repeat it multiple times across the whole query makes the query look too big and messy. 

Suggested fix:
I think this is a very simple feature to implement. 
There's a language (M) that has it as its primary way of dealing with data: all data is stored/read/written using a delimiter (chr(22)).
[16 Jan 2008 10:58] Valeriy Kravchuk
Thank you for a reasonable feature request.