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
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
You can use MySQL FIND_IN_SET() to join the tables and GROUP_CONCAT() to concat the values :
SELECT s.sno,GROUP_CONCAT(s.values) as `values`
FROM mapping t
INNER JOIN map s ON(FIND_IN_SET(s.id,t.values))
GROUP BY s.sno
Note: You should know that this is a very bad DB structure. This may lead to a lot more complicated queries and will force you to over complicate things. You should Normalize your data, split it , and place each ID
in a separate record!