MySQL split and join the values

后端 未结 2 859
心在旅途
心在旅途 2021-01-21 06:18

I have a table [mapping] with 2 columns similar to below

id  | values
1   | 1,2
2   | 1,2,3
3   | 1,1
4   | 1,1,2

and another table [map] is si

2条回答
  •  日久生厌
    2021-01-21 06:42

    SELECT
        `ids`.`id`,
        GROUP_CONCAT(`values`.`texts`) AS texts
    FROM
        `ids`
    INNER JOIN `values` ON FIND_IN_SET(`values`.`id`, `ids`.`values`)
    GROUP BY
        `ids`.`id`
    

    It works like this: Example

提交回复
热议问题