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'
我想在codeigneter中编写sql查询。
任何帮助都将受到高度赞赏。
答案 0 :(得分:1)
请试试这个:
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();
答案 1 :(得分:-1)
请试试这个,
$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();