I asked a question before and received this answer:
SELECT table1.id, GROUP_CONCAT(table2.values)
FROM table1
INNER JOIN
table2
ON FIND_IN_SET(table2.id, table1.nos)
GROUP BY
table1.id
But I have another field nos1
(with multiple values) in table1
that also pointing to table2
, I use it like this :
SELECT table1.id, GROUP_CONCAT(table2.values),GROUP_CONCAT(table2.values)
FROM table1 INNER JOIN table2 ON
FIND_IN_SET(table2.id, table1.nos),
INNER JOIN table2 ON
FIND_IN_SET(table2.id, table1.nos1),
GROUP BY table1.id
, but it is not working properly. I am not getting how to use in this situation.
Here is my data and desired resultset:
Table1:
id: no nos1
1 14,15,16 17,18
Table2:
id value
14 PHP
15 JAVA
16 C++
17 mysql
18 mysql server
Output:
id no nos1
1 PHP, JAVA, C++ mysql, mysql server