If i have field in table which include value such as (111_556_ _ _555_88). how can i get each part of the field by sql?
Parse field with underscore character
Collapse
X
-
If the pattern is the same use only SUBSTRING() as i did below
[CODE=mysql]SELECT SUBSTRING('111_ 556_ _ _555_88', 1,3) AS first_part,
SUBSTRING('111_ 556_ _ _555_88', 5,3) AS second_part[/CODE]
But if the digits are of variable length between underscores then use LOCATE() with SUBSTRING(). List of all mysql string functions can be found here http://dev.mysql.com/doc/refman/5.0/...functions.html.
Comment