我正在使用mysql 5.1。SQL,COUNT在我的mysql查詢中不起作用
這裏是我的數據庫架構
office
+--------------+----------------+
| office_id | office_name |
+--------------+----------------+
employee
+--------------+-----------------------+------------+
| employee_id | employee_hierarchy_id | office_id |
+--------------+-----------------------+------------+
employee_hierarchy
+-----------------------+-------------------------------+
| employee_hierarchy_id | employee_hierarchy_description|
+-----------------------+-------------------------------+
我想算number of employees
group by employee_hierarchy_id
每個office_id
這裏是我的要求列出factory_id和employee_hierarchy_id:
SELECT office_id, employee_hierarchy_id
FROM office, employee_hierarchy
ORDER BY office_id ASC
如果我嘗試添加計數,它只顯示一行:
SELECT office_id, employee_hierarchy_id, COUNT(*)
FROM office, employee_hierarchy
ORDER BY office_id ASC
嗨,employee_hierarchy.factory_id不存在,我已經更新我的數據庫架構,通過添加我的employee_hierarchy表。 –
@ Tom-pouce看到我的更新。 –
「字段列表」中的未知列'b.employee_hierarchy_description' –