为什么在运行MS Access查询时会得到“输入参数值"? [英] Why am I getting “Enter Parameter Value” when running my MS Access query?
问题描述
SELECT ID,
Name,
(SELECT CityName
FROM City
WHERE Employee.CityID = City.CityID) AS [City Name]
FROM Employee
WHERE [City Name] = "New York"
我要选择所有来纽约的员工,但是每当我运行查询时,我总会得到一个输入参数值"框.我该如何解决?
I'm about selecting all employees who come New York but whenever I run the query, I always get a "Enter Parameter Value" box. How can I fix this?
推荐答案
这是因为Access不允许您在查询中使用字段别名-它无法将[城市名称]识别为有效的字段名称.别名仅用作结果集中的字段名称.相反,您需要使用整个表达式.
This is because Access does not allow you to use field aliases in the query - it does not recognize [City Name] as a valid field name. Aliases are only used as field names in the result set. Rather, you need to use the entire expression.
因此,此查询在Access中可能更容易定义为:
As such, this query would probably be more easily defined in Access as:
SELECT ID,
Name,
CityName AS [City Name]
FROM Employee INNER JOIN City
ON Employee.CityID=City.CityID
WHERE CityName = "New York"
此外,名称"是保留字-不建议将其用作字段名称.
Also, 'Name' is a reserved word - using it as a field name is not suggested.
这篇关于为什么在运行MS Access查询时会得到“输入参数值"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!