Andrew Font Andrew Font - 4 months ago 5x
SQL Question

How would I use a SQL query for the following result

I have a database with the following entities:
Survey Model

Question Model

Survey Question

I also have an employee entity not shown here that has an id and name field that I would like to include in my query.

I need to create a query that if given a survey ID would return a list of results that look like this: | Survey.submitter_id | Survey.subject_id | question.text | survey_questions.answer_value |survey_questions.anonymous


I can't test the query but i think you will get the idea:

SELECT, sq.submitter_id, s.subject_id, q.text, sq.answer_value, sq.anonymous FROM surveys AS s JOIN survey_questions AS sq ON sq.survey_id = JOIN questions AS q ON sq.question_id = WHERE = <your_value>