mclamais Posted October 4, 2008 Share Posted October 4, 2008 I have a table that looks like this table1 fid name 1 Model 123 1 Model 124 2 xyz123 2 xyz999 2 abc123 I want to end up with (in a new table) fid name 1 Model 123, Model 124 2 xyz123, xyz999, abc123 Does anyone know the best way to create this? Thanks, Marc Quote Link to comment https://forums.phpfreaks.com/topic/126986-help-working-with-data/ Share on other sites More sharing options...
Chicken Little Posted October 5, 2008 Share Posted October 5, 2008 I've done this in MS Access using a crosstab query TRANSFORM First(Table1.name) AS FirstOfname SELECT Table1.fid, First(Table1.name) AS [Total Of name] FROM Table1 GROUP BY Table1.fid PIVOT Table1.ID; and then concatenation SELECT Table1_Crosstab.fid, [1] & ", " & [2] & ", " & [3] & ", " & [4] & ", " & [5] AS tag FROM Table1_Crosstab; to produce what you need. Quote Link to comment https://forums.phpfreaks.com/topic/126986-help-working-with-data/#findComment-657345 Share on other sites More sharing options...
fenway Posted October 5, 2008 Share Posted October 5, 2008 You'll need GROUP_CONCAT() in MySQL. Quote Link to comment https://forums.phpfreaks.com/topic/126986-help-working-with-data/#findComment-657575 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.