SQL错误:为什么测试表不存在?

问题描述 投票:0回答:1

我在 Leetcode 网站上进行 SQL 练习,遇到的一个常见错误是

'test table xxx doesn't exist'

我看到有人提到我没有这些表的权限,但我不明白为什么。在什么情况下我会失去对测试表的权限?例如,代码中的哪些特定错误可能会导致此问题?谢谢!

补充:例如,我试图用以下代码解决 184. Department Highest Salary 问题:

select d.Name as "Department", e.Name as "Employee", Salary
from Empolyee e
join Department d
on d.Id = e.DepartmentId
where (e.DepartmentId , Salary) in (select DepartmentId, max(Salary)
                                  from Employee
                                  group by DepartmentId)

我收到的错误是:

Table 'test.empolyee' doesn't exist

但是,下面的代码(与我上面的代码非常相似)是正确的!有人知道为什么吗?谢谢!

SELECT Department.name AS 'Department',
       Employee.name AS 'Employee',
       Salary
FROM Employee
JOIN Department 
ON Employee.DepartmentId = Department.Id
WHERE (Employee.DepartmentId , Salary) IN (SELECT DepartmentId, MAX(Salary)
                                          FROM Employee
                                          GROUP BY DepartmentId)
mysql error-handling
1个回答
0
投票

我刚刚看到这个错误弹出,原来我的表名错误。

© www.soinside.com 2019 - 2024. All rights reserved.