I have a table with 2 records:
==========
TABLE: users
==========
name_id (INT)
name (varchar)
code (int)
Inside the table I have a few records:
id name code
-----------------
1. John 233
2. Fred 211
3. John 122
4. John 555
5. Fred 444
(this is a simplified example of the actual tables so bare with me)
Now I want to select all users and COMBINE the codes and INSERT them into a
new table like this:
=============
TABLE: combined
=============
id (INT)
name (varchar)
combined_codes (varchar)
id name combined_codes
-----------------------------
1. John 233, 122, 55
2. Fred 211, 444
I have tried the CONCAT_WS statement, but code like "CONCAT_WS(',', code,
code) only combines 2 of the same codes.
Is there a way to do this?
Tnx.