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

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

121

posted @ 2015-06-16 15:08  过客代码站  阅读(179)  评论(0编辑  收藏  举报