group concat - How group_concate Mysql Select in one query -
my mysql query is:
select products_id, options_id, options_values_id products_options po, products_attributes pa pa.options_id=po.products_options_id , po.products_options_name '%velikost%' , po.language_id=7 group products_id, options_values_id
and gives output:
products_id options_id options_values_id 3 3501 13227 3 3501 13230 4 3501 13226 4 3501 13227 4 3501 13230 4 3501 13231 5 3501 13226 5 3501 13227 5 3501 13230 5 3501 13231 6 3501 13226 6 3501 13227 6 3501 13230 6 3501 13231
and wish have output this:
3 3501 '13227, 13230' 4 3501 '13226, 13227, 13230, 13231' 5 3501 '13226, 13227, 13230, 13231' 6 3501 '13226, 13227, 13230, 13231'
i trying query group_concat
select products_id, options_id, group_concat( options_values_id ) products_options po, products_attributes pa pa.options_id = po.products_options_id , po.products_options_name '%velikost%' , po.language_id =7 group products_id, options_values_id
but returns:
products_id options_id group_concat(options_values_id) 3 3501 13227,13227,13227 3 3501 13230,13230,13230 4 3501 13226,13226,13226 4 3501 13227,13227,13227 4 3501 13230,13230,13230 4 3501 13231,13231,13231 5 3501 13226,13226,13226 5 3501 13227,13227,13227 5 3501 13230,13230,13230 5 3501 13231,13231,13231 6 3501 13226,13226,13226 6 3501 13227,13227,13227 6 3501 13230,13230,13230 6 3501 13231,13231,13231
can tell me i'm doing wrong? thanks
try this.
select products_id, options_id, group_concat( options_values_id ) products_options po, products_attributes pa pa.options_id = po.products_options_id , po.products_options_name '%velikost%' , po.language_id =7 group products_id,options_id;