ASP多表查询问题?

来源:百度知道 编辑:UC知道 时间:2024/06/28 09:20:59
学生表students 包括的字段(student_id,student_num(学号),studen_name,...) 课程表courses 包括的字段(course_id,course_nem) 成绩表score 包括的字段(score_id,student_id,course_id,score(成绩))
studentnum=trim(request.form("studentnum")(文本框提交过来的值学号)
courseid=trim(request.form("courseid")
(文本框提交过来的值课程号)
根据这两个提交的值查询出 student_name,studnet_id,course_name,course_id,score
这个该多表的查询语句该怎么写啊?
两张我会的,三张了就不行了...是学的不好

sql :
select b.student_name,a.student_id,c.course_name,a.course_id,a.score
from score a
left outer join students b on a.student_id=b.student_id
left outer join course c on a.course_id=c.course_id
where b.student_num=? and a.course_id=?
其中第一个?号改成 你提交过来的学号,第二个?号改成 你提交过来的 课程ID,自己根据 字符串 连接拼好SQL

select a.*,b.*,c.socre form students as a,courses as b,score as c where c.student_id=a.student_id and c.course_id=b.course_id and a.student_id="&studentnum&" and b.course_id="&courseid

太老套的问题,找个句子自己分析下就会了。

是你sql语句学得太差了.
你在在百度搜索sql join