您可以尝试使用下面我的解决方案概念化,看看它是否能帮助,
为了避免并发症,你可以随便去直接
<?php
//connection
$link = mysqli_connect("localhost","root","","database_name") or die("Couldn't make connection.");
$computer_department_id = //the value
$query = mysqli_query($link, "SELECT department_id FROM instructure_table WHERE department_id='$computer_department_id')");
$total = mysqli_num_rows($query);
echo $total; //this one will display the total number of instructors in computer department
?>
如果你喜欢
<?php
//connection
$link = mysqli_connect("localhost","root","","database_name") or die("Couldn't make connection.");
$computer_department = //the value
$query = mysqli_query($link, "SELECT department_id
FROM instructure_table AS t
WHERE EXISTS (SELECT department_id
FROM department_table AS d
WHERE d.department_id = t.department_id AND department_id='$computer_department')");
$total = mysqli_num_rows($query);
echo $total; //this one will display the total number of instructors in computer department
?>
因此,如果您将查询放置在部门行中,即使对部门的查询位于重复区域中,它仍然适用于您。问候
我尝试'内部加入'与'组'通过',但我收到错误为'列'部门标识'字段列表中含糊不清' – Kirataka
我相信你想要这样的东西http://stackoverflow.com/questions/35340801/MySQL的选从 - 类别 - 在表-Y-其中-计数的最的categorys产物往复 –