Mysql query with burst

I have a table with this value type 20 | 10 | 5 | 8 | 19 | (with separator)

I need to select rows where the first value (e.g. after explosion) is less than 20.

$arr = explode("|", "goal_times");
$first_goal_time = $arr[0];

      

But how to do it in Mysql query?

+3


source to share


1 answer


In general, you shouldn't have multiple delimited values ​​in the same column. In this case, you can get away withSUBSTRING_INDEX()



SELECT * 
 FROM yourtable 
 WHERE 
  SUBSTRING_INDEX(yourcolumn,'|',1) < 20;

      

+1


source







All Articles