SELECT beatid,COUNT(d.id) dongnicount FROM `bed_beat_dongni` d INNER JOIN bed_beat b on b.id = d.beatid GROUP by beatid
SELECT b.*,ccc.dongnicount from bed_beat b left join(SELECT beatid,COUNT(d.id) dongnicount FROM `bed_beat_dongni` d INNER JOIN bed_beat b on b.id = d.beatid GROUP by beatid) ccc on ccc.beatid = b.id