SURVEYS
table:SurveyID
UserID
Question
Choice1
Choice2
Choice3
RESPONSES
table:UserID
SurveyID
Something like this I think should do?
SELECT *
FROM Surveys s
WHERE s.UserID != 28
AND s.SurveyID NOT IN (SELECT R.SurveyID FROM Responses R WHERE R.UserID = 28)
SELECT s.*
FROM SURVEYS s
WHERE s.userid != 28
AND s.surveyid NOT IN (SELECT r.survey_id
FROM RESPONSES r
WHERE r.userid = 28)
SELECT s.*
FROM SURVEYS s
LEFT JOIN RESPONSES r ON r.survey_id = s.surveyid
AND r.user_id = 28
WHERE s.userid != 28
AND r.userid IS NULL
SELECT s.*
FROM SURVEYS s
WHERE s.userid != 28
AND NOT EXISTS (SELECT NULL
FROM RESPONSES r
WHERE r.userid = 28
AND r.survey_id = s.surveyid)
Of the options listed, the NOT IN
and LEFT JOIN/IS NULL
are equivalent though I prefer the NOT IN
because it is more readable.