"Persons" 表:
Id_P LastName FirstName Address City
1 Adams John Oxford Street London
2 Bush George Fifth Avenue New York
3 Carter homas Changan Street Beijing
select
a.Id_P, a.LastName, IFNULL(b.num, 0) as num
from Persons
left join
(select Id_P, count(Id_p) as num
from Orders group by Id_p) as b
ON a.Id_P =b.Id_P