How do I concatenate strings from a subquery into a single row in mysql? How do I concatenate strings from a subquery into a single row in mysql? mysql mysql

How do I concatenate strings from a subquery into a single row in mysql?


by using the GROUP_CONCAT() function and a GROUP BY call. here's an example query

SELECT    p.package_id,   p.package_name,   p.price,   GROUP_CONCAT(pz.zone_id SEPARATOR ',') as zone_list FROM    package p LEFT JOIN package_zone pz ON p.package_id = pz.package_id GROUP BY    p.package_id

you should still be able to order by zone_id s (or zone_list), and instead of using LIKE, you can use WHERE zp.zone_id = 'Z1' or something similar.