0

Possible Duplicate:
Concatenate many rows into a single text string?

I have 2 tables with 1 to many relationship between them. I need to consolidate data contained in 1 column in the 2nd table and add it to corresponding single entry in the first table. How could I do that in MySQL ?

  • ID is the primary key Example:

Table 2 Calculation

ID  Forms  Calc

1    A      20

1    B      30

1    C      10 

Target Table :

Table1 Client

ID    Name     Forms

1     XYZ      A,B,C
Community
  • 1
  • 1
JJunior
  • 2,831
  • 16
  • 56
  • 66

1 Answers1

0
INSERT INTO Client (ID, Forms)
SELECT ID , GROUP_CONCAT(Forms)
FROM Calculation
GROUP BY ID 
Damith
  • 62,401
  • 13
  • 102
  • 153