Never mind.

mysql> select Dealername,pc,group_concat(pc) from ford_gb where pc='LE4
7SL' group by 1;
+------------------------+---------+------------------+
| Dealername             | pc      | group_concat(pc) |
+------------------------+---------+------------------+
| CD Bramall - Leicester | LE4 7SL | LE4 7SL          |
| CD Bramall Trucks      | LE4 7SL | LE4 7SL,LE4 7SL  |
+------------------------+---------+------------------+

Andrew 

-----Original Message-----
From: Andrew Braithwaite [mailto:[EMAIL PROTECTED] 
Sent: Wed, 11 Oct 2006 14:32
To: mysql@lists.mysql.com
Subject: Group by and concatenate

Hi,

I have the following data:

mysql> select Dealername,pc from ford_gb where pc='LE4 7SL';

+-----------------------------+---------+
| Dealername                  | pc      |
+-----------------------------+---------+
| CD Bramall Ford - Leicester | LE4 7SL | CD Bramall Ford - Leicester | 
| LE4 7SL | CD Bramall Ford - Leicester | LE4 7SL |
+-----------------------------+---------+

Is there a way in a single SQL query to group by Dealername, and have
the postcodes concatenated into a comma-separated list? e.g.

+-----------------------------+----------------------------+
| Dealername                  | concat_pc                  |
+-----------------------------+----------------------------+
| CD Bramall Ford - Leicester | LE4 7SL, LE4 7SL, LE4 7SL  |
+-----------------------------+----------------------------+

Running MySQL 4.1 on Fedora C3.

Any help appreciated,

Andrew
SQL, Query

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to