因此,這裏的SQL我有GROUP_CONCAT select語句
SELECT c.name AS 'name',
COUNT(sc.condition_id) AS 'conditions_count'
FROM reviews r, strain_conditions sc
LEFT JOIN conditions c ON sc.condition_id = c.id
WHERE sc.strain_id = 1 && sc.review_id = r.id && r.moderated = 1
GROUP BY sc.condition_id
ORDER BY conditions_count DESC
LIMIT 3;
它返回
+---------------+------------------+
| name | conditions_count |
+---------------+------------------+
| Fiber Myalgia | 2 |
| Anxiety | 2 |
| ADHD | 1 |
+---------------+------------------+
我需要做的是GROUP_CONCAT名字結果讓我最終的結果是根本
「纖維肌痛,焦慮,多動症「
你想讓他們出現在任何特定的順序或不關係呢? –