Right now, I have a rather complex query:
"SELECT h.hintCatID, hc.hintCatName, COUNT(h.hintCatID) AS hintsLeft
FROM hint h
LEFT JOIN selectedhint sh USING (hintID)
INNER JOIN hintcategory hc ON hc.hintCatID=h.hintCatID
WHERE sh.responseID != ' ".$responseID." '
OR sh.responseID IS NULL
GROUP BY h.hintCatID"
Where $responseID is the ID of the logged-in user's response.
This query screws up whenever a hint is selected as part of another response. When that occurs, hintsLeft increments by one for all other responses, even though actions taken in one response should have no effect on the others.
I realize that this query is way off, but perhaps it will help shed some light on what I am trying to accomplish.
The following text refers to this rudimentary LEFT JOIN:
"SELECT *
FROM hint h
LEFT JOIN selectedhint sh USING (hintID)"
The big problem that I'm having is that left joining selectedhint to hint only gives me NULL responseIDs for hints that haven't been viewed in any response at all.
If I am currently taking part in responseID 36, for example, and hintID #4 was viewed by any of the previous 35 respondents, then hint #4 will not show up as NULL in my result.
If I were to try to filter out records that didn't have a responseID of 36, hintID #4 would be eliminated altogether from the result.
How could I get a quick tally of the hints that haven't been viewed by responseID #36, regardless of whether they have been utilized in other responses or not?