I am working on a homework project that has 4 tables. The student logs in with first/last name and grade, and from there, I need to retrieve their homework assignments. My tables are as follows:
HS_coursetable
Field Type
id int(10)
courseid varchar(15)
sectionid varchar(10)
period tinyint(4)
room varchar(6)
staffid int(11)
coursename varchar(50)
subject varchar(50)
grade varchar(15)
HS_homework
Field Type
assignid int(11)
courseid varchar(20)
S01A varchar(4)
S02A varchar(4)
S03A varchar(4)
S04A varchar(4)
S05A varchar(4)
S06A varchar(4)
S07A varchar(4)
S08A varchar(4)
Monday date
assignMon text
assignTue text
assignWed text
assignThu text
assignFri text
staffid int(11)
HS_scheduletable
Field Type
id int(11)
courseid varchar(30)
sectionid varchar(10)
studentid nt(11)
HS_studenttable
Field Type
studentid int(10)
lastname varchar(20)
firstname varchar(20)
grade varchar(5)
In there scheduletable, there are 8 entries for each student, so that's the number of rows I need to get back. I need the student's name, grade, class period, course name, subject, week start date (Monday), and the assignments for Mon-Fri.
This is the select statment I tried, but get no rows back:
SELECT HS_studenttable.lastname,
HS_studenttable.firstname,
HS_studenttable.grade,
HS_coursetable.period,
HS_coursetable.coursename,
HS_coursetable.subject,
HS_homework.Monday,
HS_homework.assignMon,
HS_homework.assignTue,
HS_homework.assignWed,
HS_homework.assignThu,
HS_homework.assignFri
FROM HS_studenttable,
HS_scheduletable,
HS_coursetable,
HS_homework
WHERE HS_studenttable.lastname = 'Doe'
AND HS_studenttable.firstname = 'John'
AND HS_studenttable.grade = '9'
AND HS_studenttable.studentid = HS_scheduletable.studentid
AND HS_scheduletable.courseid = HS_coursetable.courseid
AND HS_scheduletable.sectionid = HS_coursetable.sectionid
AND HS_coursetable.courseid = HS_homework.courseid
AND (HS_coursetable.sectionid = HS_homework.S01A
OR HS_coursetable.sectionid = HS_homework.S02A
OR HS_coursetable.sectionid = HS_homework.S03A
OR HS_coursetable.sectionid = HS_homework.S04A
OR HS_coursetable.sectionid = HS_homework.S05A
OR HS_coursetable.sectionid = HS_homework.S06A
OR HS_coursetable.sectionid = HS_homework.S07A
OR HS_coursetable.sectionid = HS_homework.S08A)
AND HS_coursetable.staffid = HS_homework.staffid
ORDER BY HS_coursetable.period
Can anyone give me any advice on this?