Can MySQL split a column?

Viewed 171316

I have a column that has comma separated data:

1,2,3
3,2,1
4,5,6
5,5,5

I'm trying to run a search that would query each value of the CSV string individually.

0<first<5   and  1<second<3  and  2<third<4 

I get that I could return all queries and split it myself and compare it myself. I'm curious if there is a way to do this so MySQL does that processing work.

Thanks!

7 Answers

As an addendum to this, I've strings of the form: Some words 303

where I'd like to split off the numerical part from the tail of the string. This seems to point to a possible solution:

http://lists.mysql.com/mysql/222421

The problem however, is that you only get the answer "yes, it matches", and not the start index of the regexp match.

Related