Extract multiple values from one column in MySql

Posted by Neil on Stack Overflow See other posts from Stack Overflow or by Neil
Published on 2011-06-27T11:57:11Z Indexed on 2011/06/27 16:22 UTC
Read the original article Hit count: 218

Filed under:
|
|

I've noticed that MySql has an extensive search capacity, allowing both wildcards and regular expressions. However, I'm in somewhat in a bind since I'm trying to extract multiple values from a single string in my select query.

For example, if I had the text "<span>Test</span> this <span>query</span>", perhaps using regular expressions I could find and extract values "Test" or "query", but in my case, I have potentially n such strings to extract. And since I can't define n columns in my select statement, that means I'm stuck.

Is there anyway I could have a list of values (ideally separated by commas) of any text contained with span tags?

In other words, if I ran this query, I would get "Test,query" as the value of spanlist:

select <insert logic here> as spanlist from HtmlPages ...

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql