Can you split/explode a field in a MySQL query?

后端 未结 17 844
无人及你
无人及你 2020-11-22 04:03

I have to create a report on some student completions. The students each belong to one client. Here are the tables (simplified for this question).

CREATE TAB         


        
17条回答
  •  抹茶落季
    2020-11-22 04:36

    I've resolved this kind of problem with a regular expression pattern. They tend to be slower than regular queries but it's an easy way to retrieve data in a comma-delimited query column

    SELECT * 
    FROM `TABLE`
    WHERE `field` REGEXP ',?[SEARCHED-VALUE],?';
    

    the greedy question mark helps to search at the beggining or the end of the string.

    Hope that helps for anyone in the future

提交回复
热议问题