group_concat(A,' ',B,' ',C) as Name,
then using this php for displaying
<td><?php echo $row['Name']; ?></td>
using this query returns Name X,Y
but i prefer to have the names not comma separated rather line break X then Y new line
Any idea?
group_concat(A,' ',B,' ',C) as Name,
then using this php for displaying
<td><?php echo $row['Name']; ?></td>
using this query returns Name X,Y
but i prefer to have the names not comma separated rather line break X then Y new line
Any idea?
For MySQL (or plain text) output You could use \n as a separator:
SELECT GROUP_CONCAT(column1 SEPARATOR '\n') FROM table1;
I use this very often when I need to get many new-line-separated values in one row for other processing.
separator '\r\n' exported the way I wanted for ExcelI don't understand what do you mean by line break between X and Y, but if you need the values to be comma separated you can add any separator to the Group_Concat like that:
group_concat(Name SEPARATOR ' ') as Name
and here is some other separators you can use.
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;