📜  mysql 两个连接 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:33.154000             🧑  作者: Mango

代码示例1
SELECT areas.name AS aname, COUNT(consultants.active) AS cct 
    FROM areas 
    LEFT JOIN consAreas 
      ON consAreas.area = areas.id 
    LEFT JOIN consultants 
      ON consultants.id = consAreas.cons
   WHERE areas.areaID = $area 
     AND consultants.active = 1
GROUP BY areas.name
ORDER BY areas.name