I have three tables:
QUESTIONS
questionID
surveyID
RESPONSES
responseID
surveyID
ANSWERS
answerID
questionNo
responseID
I need to query the answer table, and get the questionID for which they have answered. My problem is that for some reason when I designed the database, I didnt assign the answer to the questionId. Now I need to make an SQL query to get the questionID based on the question number.
My problems is that the SQL needs to be nested I think.
The answer has a responseID (ANSWERS TABLE)
the responseID has a surveyID (RESPONSES TABLE)
the surveyID can then get the questionID (QUESTIONS TABLE)
I've tried this
Code:
select
questions.questionID
FROM questions
right join (responses.surveyID on questions.surveyID)
ON questions.surveyID = responses.surveyID
but it's probably far from perfect - as it doesnt even work.
any ideas?!
Cheers!
QUESTIONS
questionID
surveyID
RESPONSES
responseID
surveyID
ANSWERS
answerID
questionNo
responseID
I need to query the answer table, and get the questionID for which they have answered. My problem is that for some reason when I designed the database, I didnt assign the answer to the questionId. Now I need to make an SQL query to get the questionID based on the question number.
My problems is that the SQL needs to be nested I think.
The answer has a responseID (ANSWERS TABLE)
the responseID has a surveyID (RESPONSES TABLE)
the surveyID can then get the questionID (QUESTIONS TABLE)
I've tried this
Code:
select
questions.questionID
FROM questions
right join (responses.surveyID on questions.surveyID)
ON questions.surveyID = responses.surveyID
but it's probably far from perfect - as it doesnt even work.
any ideas?!
Cheers!