Hello!
I got some help writing a query a while back and am revisiting it with the hopes of speeding it up. In the past I used multiple subqueries but now realize that these guys can be super, super slow. Basically, I’d like to get all of the question id’s that fit a certain topic (The Language of Algebra), that are unused by a particular user. The user can either use a question_id as a review question (hence the ungraded_review_questions.user_id<>1 statement below) or the question is in none of their assigned HW’s for a particular course (this is the part I need help with). So far I have:
SELECT questions.question_id
FROM questions
INNER JOIN assignments_topics ON questions.section_name = assignments_topics.section_name
AND questions.question_id
LEFT JOIN ungraded_review_questions ON questions.question_id = ungraded_review_questions.question_id
WHERE assignments_topics.chapter_name = 'The_Language_of_Algebra'
AND ungraded_review_questions.user_id <> '1'
GROUP BY questions.question_id
(The GROUP BY statement is there because different users could use the same question).
I’d like to add something like:
AND question._id NOT IN
(SELECT question_id FROM assignments_questions INNER JOIN assignments_instructors ON assignments_questions.assignment_id = assignments_instructors.assignment_id WHERE assignments_instructors.course_id = 39)
In other words, the question shouldn’t be in any other HW assignments for a particular course. However, since this is a sub-query, I’m wondering if it might be better/possible to somehow integrate into the query with LEFT JOIN: I’m a little stumped because this portion of the query would include an INNER JOIN as well.
Any thoughts would be appreciated,
Eric