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

后端 未结 17 865
无人及你
无人及你 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:23

    Building on Alwin Kesler's solution, here's a bit of a more practical real world example.

    Assuming that the comma separated list is in my_table.list, and it's a listing of ID's for my_other_table.id, you can do something like:

    SELECT 
        * 
    FROM 
        my_other_table 
    WHERE 
        (SELECT list FROM my_table WHERE id = '1234') REGEXP CONCAT(',?', my_other_table.id, ',?');
    

提交回复
热议问题