mysql with comma separated values

后端 未结 1 1970
不知归路
不知归路 2020-12-11 23:51

I\'m having a problem in MySQL query.
I need MySQL query to display the following output and I also need to take CSV or Excel or PDF report.

Table1:

         


        
相关标签:
1条回答
  • 2020-12-12 00:26

    In SQL, it's better to store a single value in a column, not a comma-separated list of values. See my answer to Is storing a comma separated list in a database column really that bad?

    You can try this query, but it will be terribly slow and inefficient:

    SELECT Table1.id, GROUP_CONCAT(Table2.values) AS values
    FROM Table1
    JOIN Table2 ON FIND_IN_SET(Table2.id, Table1.nos)
    GROUP BY Table1.id;
    

    See the FIND_IN_SET() function.

    0 讨论(0)
提交回复
热议问题