在查询上动态加入表会降低性能

时间:2017-04-11 09:20:27

标签: php mysql left-join

我希望在一个列表视图中显示超过50个表的数据。我在下面形成了查询。 使用php forloop动态添加左连接。 从各种表中获取值的任何其他方法(超过50个表) 或建议使用PHP产品的任何其他技术

SELECT * FROM main_table `t`
LEFT JOIN `table` ON table.c_application_id = t.id
LEFT JOIN `table1` ON table1.c_application_id = t.id
LEFT JOIN `table2` ON table2.c_application_id = t.id
LEFT JOIN `table3` ON table3.c_application_id = t.id
LEFT JOIN `table4` ON table4.c_application_id = t.id
LEFT JOIN `table5` ON table5.c_application_id = t.id
LEFT JOIN `table6` ON table6.c_application_id = t.id
LEFT JOIN `table7` ON table7.c_application_id = t.id
LEFT JOIN `table8` ON table8.c_application_id = t.id
LEFT JOIN `table9` ON table9.c_application_id = t.id
LEFT JOIN `table10` ON table10.c_application_id = t.id
LEFT JOIN `table11` ON table11.c_application_id = t.id
LEFT JOIN `table12` ON table12.id=t.c_cycle
LEFT JOIN `table13` ON table13.c_groupId=t.c_program_to_apply
LEFT JOIN `table14` ON table14.id = table14.c_status_id 
LEFT JOIN `table15` ON table15.id = table15.c_stage_id 
LEFT JOIN `table16` ON table16.c_code = table16.c_country 
LEFT JOIN `table17` ON table17.id=table17.c_app_form

0 个答案:

没有答案