我想在编码器中编写该sql查询


    SELECT count(`idCall`) as answerCount FROM `call` WHERE 
       `idEmployee`=20 and `C_date`= '2015-04-22' and
       `C_ansornot`='Not Answer'
        SELECT count(`idCall`) as answerCount FROM `call` WHERE 
       `idEmployee`=20 and `C_date`= '2015-04-22' and
       `C_ansornot`='Rejected'
        SELECT count(`idCall`) as 
        answerCount FROM `call` WHERE 
       `idEmployee`=20 and `C_date`= '2015-04-22' and
       `C_ansornot`='Answer'
        SELECT count(`idCall`) as answerCount FROM `call` WHERE 
  `idEmployee`=20    and `C_date`= '2015-04-22' and `C_ansornot`='Not     Reachable'

我想在编码器中编写该sql查询。

任何帮助将不胜感激。

请尝试以下操作:

SELECT
    count(idCall)AS answerCount
FROM
    CALL
WHERE
    idEmployee = 20
AND C_date = '2015-04-22'
AND C_ansornot = 'Not Answer' 
$result_NA = $this->db->get_where('CALL',array('idEmployee' => 20, 'C_date' => '2015-04-22', 'C_ansornot' => 'Not Answer'))->num_rows();
SELECT
    count(idCall)AS answerCount
FROM
    CALL
WHERE
    idEmployee = 20
AND C_date = '2015-04-22'
AND C_ansornot = 'Rejected'
$result_R = $this->db->get_where('CALL',array('idEmployee' => 20, 'C_date' => '2015-04-22', 'C_ansornot' => 'Rejected'))->num_rows();
SELECT
    count(idCall)AS answerCount
FROM
    CALL
WHERE
    idEmployee = 20
AND C_date = '2015-04-22'
AND C_ansornot = 'Answer'
$result_A = $this->db->get_where('CALL',array('idEmployee' => 20, 'C_date' => '2015-04-22', 'C_ansornot' => 'Answer'))->num_rows();
SELECT
    count(idCall)AS answerCount
FROM
    CALL
WHERE
    idEmployee = 20
AND C_date = '2015-04-22'
AND C_ansornot = 'Not Reachable'
$result_NR = $this->db->get_where('CALL',array('idEmployee' => 20, 'C_date' => '2015-04-22', 'C_ansornot' => 'Not Reachable'))->num_rows();

请尝试这个,

$this->db->select("count(`idCall`) as answerCount",False)
         ->from("call")
         ->where("idEmployee",20)
         ->where("C_date",date("Y-m-d 00:00:00", strtotime(2015-04-22)))
         ->where("C_ansornot",'Not Answer')
         ->get()->result_array();
$this->db->select("count(`idCall`) as answerCount",False)
         ->from("call")
         ->where("idEmployee",20)
         ->where("C_date",date("Y-m-d 00:00:00", strtotime(2015-04-22)))
         ->where("C_ansornot",'Rejected')
         ->get()->result_array();
$this->db->select("count(`idCall`) as answerCount",False)
         ->from("call")
         ->where("idEmployee",20)
         ->where("C_date",2015-04-22)
         ->where("C_ansornot",'Answer')
         ->get()->result_array();
$this->db->select("count(`idCall`) as answerCount",False)
         ->from("call")
         ->where("idEmployee",20)
         ->where("C_date",date("Y-m-d 00:00:00", strtotime(2015-04-22)))
         ->where("C_ansornot",'Not Reachable')
         ->get()->result_array();

最新更新