Solved

MySQL / PHP help

Posted on 2014-12-13
4
134 Views
Last Modified: 2014-12-14
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?
0
Comment
Question by:detox1978
  • 2
4 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40498475
INSERT INTO table2 SELECT id,customer,GROUP_CONCAT(contact) FROM table1 GROUP BY contact

Open in new window

0
 
LVL 2

Author Closing Comment

by:detox1978
ID: 40498486
I just needed to change the GROUP BY to customer and it worked perfectly.  Thanks
0
 
LVL 58

Expert Comment

by:Gary
ID: 40498492
Oops yes
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40498833
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

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to send multiple emails at the same time in PHP 12 60
mysql ide 10 40
Loop through multiple arrays 13 28
how to use Initialization Vector for openssl_encrypt() 5 26
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question