Merchant
MerchantId Name
1 Adams Consulting
Merchant_Services
MerchantId Service
1 SEO
1 Brand Consulting
実際には、コンマ区切りのリストを取り戻すことができます:
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
結果:
MerchantID Name Services
---------- ---------------- --------------------
1 Adams Consulting Brand Consulting,SEO