mysql - SQL GROUP_CONCAT with LEFT JOIN to multiple relative rows -


i have been stuck on hours now, appreciated

i have 2 tables 'products' , 'product_subcategorys'

'products' holds unique ids 'product_subcategorys' holds multiple ids relative 'products' table

'products' id   brand 1    2    b 3     'product_subcategorys' id   subcat 1    u 1    2    u 3    u 

this query have, group 'p.id' doesn't appear work

select group_concat(p.brand) products p left join product_subcategorys s on p.id = s.id (         s.subcategory = "u"         or s.subcategory = "i"         ) groupbrand 

so problem is, want return list of brands 'product' table cant use distinct because need count multiples

i want query return brand 'a' twice, query returning 3 times since there 2 matching ids in 'product_subcategorys'

does want?

select group_concat(p.brand order p.id) products p exists (select 1               product_subcategorys s                p.id = s.id ,                     s.subcategory in ('u', 'i')              ); 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -