我是 PHP/MYSQL 新手。我有两张桌子。表员工有(id,全名),表出勤有(id,staff_id)。我打算进行查询以获取出勤表中 id 不为 Staff_id 的所有员工。下面是我的 PDO 代码:
$att = $con->prepare('SELECT member_id FROM attendance');
$att->execute();
while ($att_fetch = $att->fetch()) {
$absent = $con->prepare('SELECT * FROM members WHERE id != "'.$att_fetch['member_id'].'" ');
$absent->execute();
$absent_fetch = $absent->fetch();
echo '
<tr>
<td class="name" data-id="'.$absent_fetch['id'].'">'.ucwords($absent_fetch['fullname']).'</td>
</tr>
';
}
令人惊讶的是,这会返回出勤表中存在的所有员工。请帮帮我
holdtom