Why am I getting “Enter Parameter Value” when running my MS Access query?

匿名 (未验证) 提交于 2019-12-03 00:50:01

问题:

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?

回答1:

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.

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.



回答2:

try single quotes instead of double quotes.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!