Autor Zpráva
Michales
Profil
Zdravím dámy a pány zdejší diskuze.

Potřeboval bych poradit jak spočítat řádky ze 3 na sobě zavislých tabulek.
Ze dvou mi to jde následovnně:
select `name`, count(*) as `pocet_alb` from `interprets` left join `albums` a on a.`interpret` = interprets.`id` group by `interpret` 

Výsledek:


Teď bych potřeboval ještě přiřadit kolik má daný interpret písní.
Pro písně platí že albums.id=songs.album

Zkoušel jsem toto, ale to není správně:
select `name`, count(a.id) as `pocet_alb`, count(s.id) as `pocet_songs` from `interprets` left join `albums` a on a.`interpret` = interprets.`id` Left join songs s on s.album=a.id group by `interpret` 



Výsledek je takovýto:
Kajman
Profil
např.
count(distinct a.id) as `pocet_alb`
Michales
Profil
Kajman:
Díky, nechápu že mě to nenapadlo :-)

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0