为什么我在运行 MS Access 查询时收到“输入参数值"? [英] Why am I getting “Enter Parameter Value” when running my MS Access query?

查看:29
本文介绍了为什么我在运行 MS Access 查询时收到“输入参数值"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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 不允许您在查询中使用字段别名 - 它无法将 [City Name] 识别为有效的字段名称.别名仅用作结果集中的字段名称.相反,您需要使用整个表达式.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆