Help with Query

G

Guest

I have this query:

SELECT patient_info.BHL_interview_id AS BHL_Interview_Id,
patient_info.init_date AS Imported_Date,
patient_interview_result.score AS PHQ_Final_Score
FROM patient_info INNER JOIN patient_interview_result ON
patient_info.id = patient_interview_result.patient_id;

I need to put Q1-Q9 from the query php_extract into this query for each
BHL_Interview_Id. I am having trouble doing this. Can anyone help?


here is query php_extract:
SELECT php_extract_2.id AS id, php_extract_2.score AS score,
php_extract_2.[1] AS Q1, php_extract_2.[2] AS Q2, php_extract_2.[3] AS Q3,
php_extract_2.[4] AS Q4, php_extract_2.[5] AS Q5, php_extract_2.[6] AS Q6,
php_extract_2.[7] AS Q7, php_extract_2.[8] AS Q8, php_extract_2.[9] AS Q9
FROM php_extract_2;

Here is query php_extract_1:
SELECT patient_interview_result.id, patient_interview_result.score AS score,
multiple_choice_answer_list.value AS question_value,
interview_question_list.display_order, multiple_choice_answer_list.value
FROM interview_question_list INNER JOIN (question INNER JOIN
((multiple_choice_answer_list INNER JOIN multiple_choice_result ON
multiple_choice_answer_list.id =
multiple_choice_result.multiple_choice_answer_id) INNER JOIN
patient_interview_result ON
multiple_choice_result.patient_interview_result_id =
patient_interview_result.id) ON (question.id =
multiple_choice_result.question_id) AND (question.id =
multiple_choice_answer_list.question_id)) ON
(interview_question_list.interview_type_id =
patient_interview_result.interview_type_id) AND
(interview_question_list.question_id = question.id)
ORDER BY patient_interview_result.id, interview_question_list.display_order;

here is php_extract_2:
TRANSFORM First(php_extract_1.question_value) AS FirstOfquestion_value
SELECT php_extract_1.id AS id, php_extract_1.score AS score
FROM php_extract_1
GROUP BY php_extract_1.id, php_extract_1.score
PIVOT php_extract_1.display_order;
 
D

Duane Hookom

You don't provide any information about how you want to "put .... into...".
What are the common/related fields in the two queries?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top