Can Mysql Split a column?

前端 未结 7 1538
别那么骄傲
别那么骄傲 2020-11-22 03:00

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 s

7条回答
  •  再見小時候
    2020-11-22 03:16

    Use

    substring_index(`column`,',',1) ==> first value
    substring_index(substring_index(`column`,',',-2),',',1)=> second value
    substring_index(substring_index(`column`,',',-1),',',1)=> third value
    

    in your where clause.

    SELECT * FROM `table`
    WHERE 
    substring_index(`column`,',',1)<0 
    AND
    substring_index(`column`,',',1)>5
    

提交回复
热议问题