MySQL / PHP help

Hi All,

I have the following MySQL table

ID    Customer     Contact
1     ABC Ltd         John Smith
2     ABC Ltd         Joe Bloggs
3     XYZ Ltd         Tom Jones
4     XYZ Ltd         Andy Murray

Open in new window


I need to get this into an new table as

ID    Customer     Contact
1     ABC Ltd         John Smith,Joe Bloggs
2     XYZ Ltd         Tom Jones,Andy Murray

Open in new window



Any suggestions?
LVL 2
detox1978Asked:
Who is Participating?
 
GaryConnect With a Mentor Commented:
INSERT INTO table2 SELECT id,customer,GROUP_CONCAT(contact) FROM table1 GROUP BY contact

Open in new window

0
 
detox1978Author Commented:
I just needed to change the GROUP BY to customer and it worked perfectly.  Thanks
0
 
GaryCommented:
Oops yes
0
 
Ray PaseurCommented:
Any MySQL book by Vikram Vaswani will give you a good foundation.  I have an older one (MySQL 4) and it still covers almost everything I need to do!
http://mysql-tcr.com/book/
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.