SQL Stymied ASP

SQL Stymied ASP

am 30.09.2005 19:20:52 von number cruncher

I'm new to asp AND sql server, literally had this job thrown at me and
I need some help from you pro's out there. I have 3 tables in a sql
server database.

Table 1 "tblStudentInfo" contains student info and each has a unique
ID.

Table 2 "tblCourses" contains info on 75 available courses that
students can take and again, each has a unique ID.

Table 3 "tblExamResults" is a sort of look-up table that contains
studentID, courseID, which relate back to tables 1 & 2 respectivly, and
a Pass/Fail field .

What I'm asked to do is...
1.) list ALL the students
2.) list wether or not they took 2 specific exams.
3.) save the result in a text file.

The text file part I'm not worried about, I read a few tutorials
yesterday and think I got it ironed out. But I haven't been able to
solve the SQL call. I just get query results that only show students
who have taken 1 of the 2 exams. I need to show them all and if they
haven't taken the couse yet, flag it somehow.

This is my last SQL Call. Can provide sample data if needed.

SELECT tblStudentInfo.lName, tblStudentInfo.fName,
tblStudentInfo.eMail, tblExamResults.examPassFail,
tblCourses.CourseCode, tblCourses.CourseRevision, tblCourses.CourseName
FROM tblStudentInfo INNER JOIN tblExamResults ON
tblStudentInfo.tblStudentID = tblExamResults.examStudentID INNER JOIN
tblCourses ON tblExamResults.examCourseID = tblCourses.CourseID WHERE
(tblCourses.CourseCode = N'IS-26') AND (tblCourses.CourseRevision =
N'1') OR (tblCourses.CourseCode = N'IS-47') AND
(tblCourses.CourseRevision = N'1')

Re: SQL Stymied ASP

am 30.09.2005 20:36:24 von Bob Barrows

"number cruncher" wrote in message
news:1128100852.577024.59250@f14g2000cwb.googlegroups.com...
> I'm new to asp AND sql server, literally had this job thrown at me and
> I need some help from you pro's out there. I have 3 tables in a sql
> server database.
>
> Table 1 "tblStudentInfo" contains student info and each has a unique
> ID.
>
> Table 2 "tblCourses" contains info on 75 available courses that
> students can take and again, each has a unique ID.
>
> Table 3 "tblExamResults" is a sort of look-up table that contains
> studentID, courseID, which relate back to tables 1 & 2 respectivly, and
> a Pass/Fail field .
>
> What I'm asked to do is...
> 1.) list ALL the students
> 2.) list wether or not they took 2 specific exams.
> 3.) save the result in a text file.
>
> The text file part I'm not worried about, I read a few tutorials
> yesterday and think I got it ironed out. But I haven't been able to
> solve the SQL call. I just get query results that only show students
> who have taken 1 of the 2 exams. I need to show them all and if they
> haven't taken the couse yet, flag it somehow.
>
> This is my last SQL Call. Can provide sample data if needed.
>
You need to read up on outer joins. This concept will be the key to your
problem. Check out the article about joins in SQL Books Online (BOL) - if
you've installed sql server or the client tools on your machine, you will
find BOL in your Start menu.

Bob Barrows