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

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

    Here's what I've got so far (found it on the page Ben Alpert mentioned):

    SELECT REPLACE(
        SUBSTRING(
            SUBSTRING_INDEX(c.`courseNames`, ',', e.`courseId` + 1)
            , LENGTH(SUBSTRING_INDEX(c.`courseNames`, ',', e.`courseId`)
        ) + 1)
        , ','
        , ''
    )
    FROM `clients` c INNER JOIN `clientenrols` e USING (`clientId`)
    

提交回复
热议问题