how to use sql join in mysql

前端 未结 4 1085
礼貌的吻别
礼貌的吻别 2021-01-23 07:33

table name: tbl_schedule

tr_id(P.K.)  mr_id(F.K.)   sch_date   doctor_id   
-----------  -----------   --------   ----------
1              23         01/01/2012         


        
4条回答
  •  不思量自难忘°
    2021-01-23 08:12

    This should be what you need:

    SELECT
      mr_fname,
      mr_lname,
      COUNT(DISTINCT tr_id)
    FROM
      tbl_user
    LEFT JOIN
      tbl_schedule USING (mr_id)
    GROUP BY
      mr_id
    

提交回复
热议问题