mySQL: Joining three tables - how?

前端 未结 2 398
情歌与酒
情歌与酒 2021-01-24 00:07

I have the following query in my application. It works well, but I need it to also contain the number of products that are associated with each manufacturer.

The current

2条回答
  •  离开以前
    2021-01-24 00:35

    select * 
    from `manufacturers` m
    inner join `languages` l on m.`lang` = l.`id` 
    left outer join (
        select manufacturerid, count(*) as ProductCount
        from Products
        group by manufacturerid
    ) pc on m.id = pc.manufacturerid
    order by l.`id` asc, m.`id` asc 
    

提交回复
热议问题