说明没有betweenand运算符时出现错误,但是我有一个and,所以我不明白。先感谢您

Syntax Error

A picture of the question

select
    a.student_name, a.test_score, b.letter_grade
from
     sec1311_student_scores a
inner join
     sec1311_grade_ranges b on a.testscore between b.beginning_score and b.endingscore
order by
    a.student_name;

最佳答案

Access在连接子句中不支持BETWEEN。从the documentation:

FROM table1 INNER JOIN table2 ON table1.field1 compopr table2.field2
The INNER JOIN operation has these parts:

Part           | Description
----           | -------------
table1, table2 | The names of the tables from which records are combined.
field1, field2 | The names of the fields that are joined. If they are not numeric, the fields must be of the same data type and contain the same kind of data, but they do not have to have the same name.
compopr        | Any relational comparison operator: "=," "<," ">," "<=," ">=," or "<>."

但是,您可以指定多个连接条件,因此您应该能够:
select
    a.student_name, a.test_score, b.letter_grade
from
     sec1311_student_scores a
inner join
     sec1311_grade_ranges b on a.testscore >= b.beginning_score
                        and on a.testscore <= b.endingscore
order by
    a.student_name;

10-07 22:33