Med en LEFT JOIN
:
select t1.name Country, count(distinct t2.name) Count
from country t1 left join cities t2
on t2.name like concat('%, ', t1.name)
group by t1.name
Se demoen
.
Resultater:
| Country | Count |
| ------- | ----- |
| France | 2 |
| Italy | 1 |
| USA | 2 |