i是登录信息中储存的登录的学号sno信息的一个变量,之前已经定义了。没有错误。错误就在SQL语句中。有四个表,分别用sno,tno,cno三个字段将四张表联系起来。具体语句在下面。说and附近有语法错误。
with ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from student,grade where student.sno=grade.sno');
SQL.Add('tname as 教师,grade as 分数');
SQL.Add('from course,teacher,grade,student');
SQL.Add('course.cno=grade.cno and teacher.tno=grade.tno and student.sno=grade.sno');
SQL.Add('and student.sno='''+i+'''');
Open;
end;
还是不对啊。 之前的语句复制错了。我写的应该是下面的语句。还是那个问题。
with ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select student.sno as 学号,course.cno as 课程号,cname as 课程,score as 学分,');
SQL.Add('tname as 教师,grade as 分数');
SQL.Add('from course,teacher,grade,student');
SQL.Add('course.cno=grade.cno and teacher.tno=grade.tno and student.sno=grade.sno');
SQL.Add('and student.sno='''+i+'''');
Open;
end;
|