I have 3 tables in my database. The tables are:
tblExams:
examid
examname
etc...
tblExamQuestions
id
examid
questionid
tblQuestions
questionid
questiontext
etc...
I need a query to return a list of all questions, regardless of whether they have been used in an exam, but also reutn a field denoting that they have been used. So far I have this SQL but it returns duplicate values...it seems no matter hwo I tweak it I cant get what I want...
Code:
SELECT q.questionid, questiontext, "isused"=
CASE WHEN e.name IS NULL THEN
0
ELSE
1
END
FROM tblQuestions As q
LEFT OUTER JOIN tblExamQuestions As eq ON eq.questionid = q.id
LEFT OUTER JOIN tblExam As e ON e.id = eq.poolid
-------------------------
Beware of programmers with screwdrivers...