group_concat MYSQL new line

后端 未结 4 1562
逝去的感伤
逝去的感伤 2020-12-06 10:00
group_concat(A,\' \',B,\' \',C) as Name,

then using this php for displaying

         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 10:39

    Example

    SELECT Name, GROUP_CONCAT(city SEPARATOR '\n') AS city, nb
    FROM
    (SELECT 'A' AS Name, 'Agra' AS city, 101 AS nb
    UNION ALL
    SELECT 'B' AS Name, 'Delhi' AS city, 102 AS nb
    UNION ALL
    SELECT 'A' AS Name, 'Allahabad' AS city, 101 AS nb) AS a
    GROUP BY Name, nb;
    

提交回复
热议问题