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
デモ
をご覧ください。 。
結果:
| Country | Count |
| ------- | ----- |
| France | 2 |
| Italy | 1 |
| USA | 2 |