我有一个关于如何根据员工性别找到工资歧视的问题。我有MS Acess 2007,必须使用SQL查询来解决它
请记住,这是在我将3个表连接成一个多表查询之后。在此查询中,每当我想要使用ORDER BY Salary
对任何列进行排序时,它会给出一个错误标记:
Syntax error (missing operator) in query expression 'Salary'
WHERE JobClass.JobClassID = Employees.JobClassID
AND Department.DepartmentID = Employees.DepartmentID'.
我想尝试在查询中对多个列进行排序。
以下是多个查询代码:
SELECT JobClass.JobClassID, JobClassName, Department.DepartmentID,
DepartmentName, LastName, FirstName, Title, Sex, Years, Salary
FROM JobClass, Employees, Department
ORDER BY 'Salary'
WHERE JobClass.JobClassID = Employees.JobClassID AND Department.DepartmentID = Employees.DepartmentID;
答案 0 :(得分:1)
按条款排序应该在where子句
之后
试试这个
SELECT JobClass.JobClassID, JobClassName, Department.DepartmentID,
DepartmentName, LastName, FirstName, Title, Sex, Years, Salary
FROM JobClass, Employees, Department
WHERE JobClass.JobClassID = Employees.JobClassID AND Department.DepartmentID = Employees.DepartmentID
ORDER BY Salary
SLECT语法
SELECT [predicate] { * | table.* | [table.]field1 [AS alias1] [, [table.]field2 [AS alias2] [, …]]}
FROM tableexpression [, …] [IN externaldatabase]
[WHERE… ]
[GROUP BY… ]
[HAVING… ]
[ORDER BY… ]
[WITH OWNERACCESS OPTION]
答案 1 :(得分:0)
除非Access '07完全忽视标准SQL(我认为不这样做),否则你的SQL语法就会关闭。
不是在ORDER BY
WHERE
子句之前放置WHERE
,而应该在 {{1}}之后。