与加入 MS Access 数据库相关的问题

问题描述:

我在 MS Access 数据库中使用以下查询:

I am using the following query in an MS Access database:

SELECT SD.RollNo, SD.Name , ED.ExamName, (
    SELECT count(*) 
    FROM (
        SELECT DISTINCT innerED.StudentId 
        FROM ExamDetails innerED 
        WHERE innerED.StudentId=SD.StudentId 
    )
) AS StudentId
FROM StudentDetails SD 
LEFT OUTER JOIN ExamDetails ED 
    ON SD.StudentId= ED.StudentId

每当我执行此查询时,都会出现一个对话框并询问参数 SD.StudentId 的值.它为什么要这样做,我该如何阻止它这样做?

Whenever I execute this query, a dialog box comes up and asks for the value of the parameter SD.StudentId. Why is it asking for this, and how do I stop it from doing so?

MS Access 不理解计数 (*) 聚合上的 SELECT 语句.访问 SQL 语句如下所示.

MS Access does not understand the SELECT statement on the Count (*) Aggregate. To Access the SQL Statement looks like this.

 SELECT DISTINCT innerED.StudentId
 FROM ExamDetails innerED 
 WHERE innerED.StudentId=SD.StudentId 

因为别名 AS STUDENTID 出现在语句的结尾之后,这个 Select 语句不能识别它,所以它不知道 .StudendID 是什么,所以它假设它是一个参数.

Because the alias AS STUDENTID comes after the end of the statement, this Select statement doesn't recognize it, so it has no idea what .StudendID is so it assumes it's a parameter.

MS Access,当遇到查询本身未识别的参数时,会提示用户输入一个值.

MS Access, when faced with a parameter that has not been identified in the query itself will prompt the user for a value.

重写查询,以便此 Select 语句可以识别所有表源.

Rewrite the query so that this Select statement can identify all the table sources.