在表codeigniter的连接中组合具有不同值的列

时间:2016-07-27 08:22:04

标签: php codeigniter join mysqli

我有4个表,而执行此查询则返回

SELECT * FROM couns_form加入education_detail ON couns_formform_id = education_detailform_id加入work_experience ON {{ 1}}。couns_form = form_idwork_experience加入form_id ON course_descriptioncouns_form = form_id。{{1} } WHERE course_descriptionform_id ='16'

couns_form

我想要一个像

这样的数组的结果
form_id

NOw:查询是否可行,或者我必须使用PHP函数完成此操作..帮助谢谢

1 个答案:

答案 0 :(得分:0)

您的查询应该是这样的

SELECT * FROM couns_form JOIN education_detail ON couns_form.form_id=education_detail.form_id JOIN work_experience ON couns_form.form_id=work_experience.form_id JOIN course_description ON couns_form.form_id=course_description.form_id WHERE couns_form.form_id = '16' GROUP BY couns_form.form_id

希望这会有所帮助