我有一个样本数据
mobile(id, name)
mobile(1, 'Nokia')
mobile(2, 'Samsung')
mobile(3, 'Motorola')
和类别
categories(id, name, mobile_id)
categories(1, 'mobile', '1,2,3')
和mysql:
SELECT cat.name as cat_name, GROUP_CONCAT(mobile.name) as mobile_name
FROM `mobile` as mobile
LEFT OUTER JOIN `categories` AS cat ON cat.mobile_id = mobile.id
这个结果如何:
(1,"mobile","Nokia,Samsung,Motorola")