我有一個簡單的數據使用GROUP_CONCAT時出錯?
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")