I'm working to create a quiz website. But i have a problem with (How to denied the viewed questions for a member).
Let's me explain it:
I've 3 table in my database.
The first table called "members" to store the members details like memberID, memberName, etc...
The second table called "denied_questions" is stored the answered questions and it's contains two field (qustionID, memberID).
The third table called "questions" is contains the questions list.
Now. I want to get a random question from questions table. The question should not be viewed to the member in the past.
The following SQL does not working!
`questions` AS qus,
`denied_qus` AS denied
denied.memberID != 3 AND qus.qusID != denied.qusID
ORDER BY RAND()
I just want to get a random question from the questions table and compare this question with the answered questions from the "denied_questions"
Any idea please?
Wow great! we can do it via Outer Joins!
Thank you "r937"
Let me to read something about OUTER JOINS
welcome to left outer joins
FROM questions AS qus
JOIN denied_qus AS denied
ON denied.qusID = qus.qusID
AND denied.memberID = 3
WHERE denied.qusID IS NULL
BY RAND() LIMIT 1