I have a MySQL table with just a column with one text type with a lot of information in the same format starting from a row such as:
Field1 : 1234 Field2 : Something
The column always starts with Field1 and Field2 , but the values after each field are different for each record.
I need to get only the values of what is after Field1 and Field2 (in this case 1234 and Something ), the value after Field1 is easy, because it is always 4 characters long, but the problem is after Field2 , because the size depends on each record, what i have so far:
SELECT SELECT substring(substring_index(COLUMN,'Field1 : ',-1),1,4) as Field1_value FROM table
I know that after Field2, the value has a line break, so I'll think about using the \ n character to delimit the desired value.
How to get this substring of variable size for each row?
PS Yes, the data is terribly structured, I can’t change it ...
source share