php - MySQL join on data from two tables -
i trying make mysql query joins multiple tables have problems 1 join part. here query:
select cs.survey_id, csq.question_id, csq.text question_text, cso.option_id, cso.text option_text, cstr.text text_question_result, count(csr.option_id) votes customer_survey cs inner join customer_survey_questions csq on cs.survey_id=csq.survey_id inner join customer_survey_options cso on cso.question_id=csq.question_id inner join customer_survey_results csr on cso.option_id=csr.option_id inner join customer_survey_text_results cstr on csq.question_id=cstr.question_id inner join customers c on c.customer_id= ??? cs.survey_id='$this->survey_id' group csr.option_id order csq.ord, cso.ord
the problem this:
the last join supposed join previous tables "customers" table on field customer_id. problem there 2 tables may include records in field - "customer_survey_results" table, , "customer_survey_text_results" table.
so, possible customer_survey_results have record of 1 customer_id, , customer_survey_text_results have none, , vice versa. how can join?
any appreciated.
Comments
Post a Comment