sql查询很长,所以需要很长时间才能获取

时间:2017-05-02 10:52:26

标签: php mysql

$sqla = <<<EOT
  SELECT
      jm.name,
      sum(m_01) as jantot,
      sum(m_02) as febtot,
      sum(m_03) as martot,
      sum(m_04) as aprtot,
      sum(m_05) as maytot,
      sum(m_06) as juntot,
      sum(m_07) as jultot,
      sum(m_08) as augtot,
      sum(m_09) as septot,
      sum(m_10) as octtot,
      sum(m_11) as novtot,
      sum(m_12) as dectot,
      (IFNULL(SUM(m_01), 0) + IFNULL(SUM(m_02), 0) + IFNULL(SUM(m_03), 0) + IFNULL(SUM(m_04), 0) + IFNULL(SUM(m_05), 0) + IFNULL(SUM(m_06), 0) +  IFNULL(SUM(m_07), 0) + IFNULL(SUM(m_08), 0) + IFNULL(SUM(m_09), 0) + IFNULL(SUM(m_10), 0) + IFNULL(SUM(m_11), 0) + IFNULL(SUM(m_12), 0)) as gtot
  FROM
      jr1_$year s,
      resourcelist m ,
      `journalmaster` jm
  WHERE
      jm.journalid = s.journalid
      AND jm.Platform = m.platform
      AND m.univ_id=s.univ_id
      AND m.Year = :year
      AND m.report = 'jr1'
      AND m.memID = :memID
      AND m.resource = :resource
  GROUP BY
      jm.name
  ORDER BY
      gtot DESC
EOT;


$sql_statement1 = $infistat->prepare($sqla);
$sql_statement1->bindParam(':year', $year, PDO::PARAM_STR);
$sql_statement1->bindParam(':memID', $memID, PDO::PARAM_INT);
$sql_statement1->bindParam(':resource', $resource, PDO::PARAM_STR);
$sql_statement1->execute();
$result_table = $sql_statement1->fetchAll(PDO::FETCH_ASSOC);

任何建议??

0 个答案:

没有答案