I have these three tables
Courses
course ID course Name course start time course end time
1 Math 10:00:00 11:00:00
2 Science 11:00:00 12:00:00
3 geography 09:00:00 10:00:00
student_courses
course ID student ID Final cost
1 2 100
2 3 200
Students
student ID student name
1 AAAA
2 BBBB
I need a select statement to place in a stored procedure to only return [Course ID], [Course name] column values of the courses that a student is not enrolled in (achieved)
AND check the student current courses’ start and end times and only return courses in which times the student is available (doesn’t have a class)
my select statement that only return courses that the student is not enrolled in::
SELECT [Course ID], [Course name]
FROM Courses
WHERE [Course ID] NOT IN
(SELECT Course ID from student_courses WHERE [student ID]=1)
How can i edit this statement to include the available time condition (knowing i want to put it in a stored procedure)….
This is the query you need:
I see no reason, why this should be in a
stored procedure. Aviewmight be reasonable.Read more about
viewshere.