drewrockshard
drewrockshard

Reputation: 2071

MySQL extract results by delimeter

I have a quick (hopefully simple) question. I have some information stored in a MySQL database:

|info1=value1
|info2=value2
|info3=value3
|info4=value4
|info5=value5
|info6=value6

I need to be able to get a certain set of information form this. Let's pretend that this set of data is in each record in a table called options. I need to be able to extract info3 value information, meaning that I need to (for every record) recieved the "value3" section of the record. I don't need "|info3=", just the "value3"; the actual value of "value3" is different for each record.

Upvotes: 0

Views: 100

Answers (1)

theMage
theMage

Reputation: 159

You question is simple, alright.

I don't think the same can be told about the answer:

select substring_index(
    substring_index(
       old_text
       ,'info3=',-1),'|',1)
from mw_text;

This should do what you want.

BUT, I really hope that this is just for play, otherwise, I would recomend that you review your database design.

Upvotes: 1

Related Questions