Sample table: employees +-------------+-------------+-------------+----------+--------------------+------------+------------+----------+----------------+------------+---------------+ | EMPLOYEE_ID | FIRST_NAME | LAST_NAME | EMAIL | PHONE_NUMBER | title |companyID +-------------+-------------+-------------+----------+--------------------+------------+------------+----------+----------------+------------+---------------+ | 100 | Steven | King | SKING | 515.123.4567 | IT_PROG | 1241 | 101 | Neena | Kochhar | NKOCHHAR | 515.123.4568 | IT_PROG | 1241 | 102 | Lex | De Haan | LDEHAAN | 515.123.4569 | IT_PROG | 1241 | 103 | Alexander | Hunold | AHUNOLD | 590.423.4567 | IT_PROG | 1241 | 104 | Bruce | Ernst | BERNST | 590.423.4568 | FI_MGR | 1242 | 105 | David | Austin | DAUSTIN | 590.423.4569 | FI_MGR | 1242 | 106 | Valli | Pataballa | VPATABAL | 590.423.4560 | FI_MGR | 1242 | 107 | Diana | Lorentz | DLORENTZ | 590.423.5567 | IT_PROG | 1242 | 108 | Nancy | Greenberg | NGREENBE | 515.124.4569 | FI_ACCOUNT |1300 | 109 | Daniel | Faviet | DFAVIET | 515.124.4169 | FI_ACCOUNT |1300 | 110 | John | Chen | JCHEN | 515.124.4269 | FI_ACCOUNT |1300 | | +-------------+-------------+-------------+----------+--------------------+------------+------------+----------+----------------+------------+--现在,当我单击员工名字表时,将打开一个单独的页面profile.php ,我使用以下代码提取标题但我没有计算特定公司的员工总数,在profile.php页面示例 1241 (companyID) 中有 4 名员工。我会怎么做?
1 回答
MMMHUHU
TA贡献1834条经验 获得超8个赞
您可以使用以下查询在 companycount 键中查询公司的返回计数
$query1 = mysqli_query($connection,"SELECT employees.EMPLOYEE_ID,employees.companyID,employees.title,(select count(*) from employees as emp where emp.companyID = employees.companyID) as companycount FROM employees where employees.EMPLOYEE_ID= $id");
- 1 回答
- 0 关注
- 88 浏览
添加回答
举报
0/150
提交
取消