I\'ve got a table with a field for Merchant\'s name and field with the Services they provide. The Services field is a comma separated list of integers that relate to another
Merchant
MerchantId Name
1 Adams Consulting
Merchant_Services
MerchantId Service
1 SEO
1 Brand Consulting
You can actually get a comma separated list back:
SELECT m.*, GROUP_CONCAT(ms.Service) AS Services
FROM Merchant m
LEFT JOIN Merchant_Serivces ms
ON ms.MerchantId = m.MerchantId
GROUP BY m.MerchantId
ORDER BY m.Name, ms.Service
Results in:
MerchantID Name Services
---------- ---------------- --------------------
1 Adams Consulting Brand Consulting,SEO