mysql join count lines in third table -


i have 3 mysql-tables this:

client                   network                   activities \_id                     \_id                      \_id \_name                   \_name                    \_client_id \_[...]                  \[...]                    \_[...] \_network_id 

now want have following result:

client.*, network.name, number_of_activities_for_each_client 

actually have select-statement:

select client.*, network.name  client  left join network  on client.network_id = network.id 

how extend statement? see clients.

select c.*, n.name, count(a.id) number_of_activities_for_each_client clients c left join network n on n.id = c.network_id left join activities on a.client_id = c.id group c.id 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -