SQL 语句优化
程序员文章站
2022-06-11 08:09:41
...
$searchlist = array( array("id" => 3, "id2" => 16, "flat" => 1), array("id" => 5, "id2" => 6, "flat" => 1), array("id" => 2, "id2" => 3, "flat" => 2), array("id" => 9, "id2" => 1, "flat" => 2), array("id" => 6, "id2" => 4, "flat" => 1),);$searchresult = "";foreach($searchlist as $k=>$v){ if($v['flat'] == 1){ $sql = sprintf("select insurance_entitle1 as title1 from %s_insurance where insurance_id = %d", $this->tablepre, $v['id']); $result = $this->db->get_one($sql); $searchresult[$k]['title1'] = isset($result['title1']) ? $result['title1'] : ""; $sql = sprintf("select insurance_encontent as content from %s_insurance_section where insurancese_section=%d order by insurancese_order", $this->tablepre, $v['id']); $result = $this->db->get_one($sql); $searchresult[$k]['content'] = isset($result['content']) ? $result['content'] : ""; $searchresult[$k]['flat'] = $v['flat']; $searchresult[$k]['id'] = $v['id']; }elseif($v['flat'] == 2){ $sql = sprintf("select insurance_entitle1 as title1 from %s_insurance where insurance_id = %d", $this->tablepre, $v['id2']); $result = $this->db->get_one($sql); $searchresult[$k]['title1'] = isset($result['title1']) ? $result['title1'] : ""; $sql = sprintf("select insurance_encontent as content from %s_insurance_section where insurancese_id=%d order by insurancese_order", $this->tablepre, $v['id']); $result = $this->db->get_one($sql); $searchresult[$k]['content'] = isset($result['content']) ? $result['content'] : ""; $searchresult[$k]['flat'] = $v['flat']; $searchresult[$k]['id'] = $v['id']; $searchresult[$k]['sid'] = $v['id2']; }}
回复讨论(解决方案)
没有看到 SQL,只看到 php
上一篇: 微信消息体加密php版
下一篇: 11行php+js 求改错
推荐阅读
-
SQL SERVER 2014 安装图解教程(含SQL SERVER 2014下载)
-
SQL SERVER数据库的作业的脚本及存储过程
-
深入浅析SQL Server 触发器
-
SQL SERVER占用CPU过高排查和优化
-
sql server中随机函数NewID()和Rand()
-
使用NotePad++录制宏功能如何快速将sql搜索条件加上前后单引号
-
修改SQL-SERVER数据库表结构的SQL命令附sql命令行修改数据库
-
浅谈基于SQL Server分页存储过程五种方法及性能比较
-
利用ROW_NUMBER() OVER函数给SQL数据库中每一条记录分配行号的方法
-
sql server代理中作业执行SSIS包失败的解决办法