Hello.

There are 2 tables: Groups and musicians. It is necessary to display the name of the groups and the number of musicians in each of them.

Table structure:

groups (id_group, title) artist(id_artist,id_group,name) 

How to write this query?

    2 answers 2

     SELECT count(a.id_artist), b.title FROM artist a LEFT JOIN groups b ON a.id_group = b.id_group GROUP BY a.id_group; 
       SELECT count(*), `id_group` FROM `artist` GROUP BY `id_group`; 

      Something like this...