SQL语句备忘
SELECT beatid,COUNT(d.id) dongnicount FROM `bed_beat_dongni` d INNER JOIN bed_beat b on b.id = d.beatid GROUP by beatid
![122 122](https://images0.cnblogs.com/blog/323088/201506/161508199983423.png)
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