Why am I getting “Enter Parameter Value” when runn

2020-04-04 05:44发布

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?

3条回答
冷血范
2楼-- · 2020-04-04 06:05

Another thing to check is on the Home tab if you have any manual sorts or filters active on the query results. There is a button on that tab to remove sorting that you wont find on the dropdown menu for the field.

查看更多
Emotional °昔
3楼-- · 2020-04-04 06:27

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.

查看更多
我想做一个坏孩纸
4楼-- · 2020-04-04 06:32

try single quotes instead of double quotes.

查看更多
登录 后发表回答