我有一個現有的SQL查詢在SQL Server中正常工作,我想在MySQL中工作。我把它清理了一下,用列表/表格名稱等的後退標記來擺弄,但無法使其工作。mySQL中的嵌套select語句
這裏是有問題的聲明:
SELECT `EmployeeID`
FROM `Employee`
WHERE
(
(
SELECT COUNT(*) AS A
FROM `TimeClock`
WHERE (`EmployeeID` = `Employee.EmployeeID`)
AND (`InOut` = 'True')
) > (
SELECT COUNT(*) AS B
FROM `TimeClock` AS `TimeClock_1`
WHERE (`EmployeeID` = `Employee.EmployeeID`)
AND (`InOut` = 'False')
)
)
這應該返回必須在TimeClock
表的詳細InOut = True
超過InOut = False
任何EmployeeID
的。
謝謝。
你得到的錯誤是什麼? – Zohaib
Error'Unknown column'Employee.EmployeeID'in'where clause'' – Fuginator