我决定做的是使用 2 个不同的查询:
$consulta= "SELECT * FROM Dept INNER JOIN Userinfo
ON Userinfo.Deptid = Dept.Deptid
where Dept.DeptName = '$departamento'";
和
$consulta2 = "SELECT * FROM Checkinout, Userinfo
where Checkinout.Userid = '$userid' AND Userinfo.userid = '$userid' AND
Checkinout.Checktime BETWEEN CDate('$fecha1') AND CDate('$fecha2')";
第一个选择属于一个部门的所有人员,第二个查找一个人的所有 IN 和 OUT。两者都可以在一段时间内查看第一个结果的每个寄存器并检查另一个查询
搜索仍然有问题,它不能正常工作,我试图做一个完整的查询,它同时在 3 个表中搜索,但它给了我一个错误:
$toda_consulta= "SELECT *
FROM Dept
INNER JOIN Userinfo ON (Dept.Deptid = Userinfo.Deptid)
INNER JOIN Checkinout ON (Checkinout.Userid = Userinfo.Userid)
WHERE Dept.DeptName = '$departamento' AND
Checkinout.Checktime BETWEEN CDate('$fecha_inicio') AND CDate('$fecha_fin')";
错误:Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][Controlador ODBC Microsoft Access] sintax error (missing operator) in the expression '(Dept.Deptid = Userinfo.Deptid) INNER JOIN Checkinout ON (Checkinout.Userid = Userinfo.Userid)'., SQL state 37000 in SQLExecDirect in C:\wamp\www\casa 7-9-13\calcula_departamento1.php on line 51
比你的帮助