Jump to content

[SOLVED] Merging data


brob

Recommended Posts

Hi can someone help.

 

I need to pull this info from a database and merge it based on the secondary_id can anyone suggest how?

 

id  secondary_id  name  desc

-------------------------------

1  27                  toy    sega

2  27                  toy    nintendo

3  32                  cd      coldplay

4  32                  cd      nelly

Link to comment
https://forums.phpfreaks.com/topic/37292-solved-merging-data/
Share on other sites

SELECT name, GROUP_CONCAT(`desc` SEPARATOR ', ') AS items FROM table GROUP BY secondary_id;

yields:

+------+-----------------+

| name | items          |

+------+-----------------+

| toy  | sega, nintendo  |

| cd  | coldplay, nelly |

+------+-----------------+

 

Link to comment
https://forums.phpfreaks.com/topic/37292-solved-merging-data/#findComment-178250
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.