两张表联合查询,并统计其中一张表在关联条件下的数据个数

 

SELECT a.dfsname, COUNT(b.dfsid) AS instnum FROM tbl_dfslist a LEFT JOIN tbl_instance b ON a.id = b.dfsid GROUP BY a.id;

(其中tbl_dfslist.id = tbl_instance.dfsid)

    原文作者:password-u
    原文地址: https://blog.csdn.net/u013992330/article/details/79021966
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞