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开发者_如何学C 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.
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.
精彩评论