------------------------------------------------
ID | Member Name | Zone | Created_Date |
------------------------------------------------
1 | foo | Zone1 | 2015-02-23 |
2 | bar | Zone1 | 2015-02-23 |
3 | foo1 | Zone2 | 2015-02-23 |
4 | baar1 | Zone2 | 2015-02-23 |
5 | foo3 | Zone1 | 2015-02-23 |
------------------------------------------------
------------------------------------------------------------
ID | Member ID | Car | Zone | Created_Date |
------------------------------------------------------------
1 | 1 | Civic | Zone1 | 2015-02-23 |
2 | 1 | BMW | Zone2 | 2015-02-23 |
3 | 2 | Vitz | Zone1 | 2015-02-23 |
4 | 2 | BMW | Zone1 | 2015-02-23 |
5 | 3 |Honda City | Zone2 | 2015-02-23 |
------------------------------------------------------------
我想在分类帐中输入一些条目,以防止区域中的汽车注册
喜欢
在第1区今天注册了多少张卡?
我可以处理单个区域,但如何管理多个项目
我正在使用codeigniter并尝试这样
public function distribute_commision()
{
$this->db->where('Is_Active', 0);
//$this->db->where('Sort_Order', 4);
$this->db->select('ID');
$this->db->select('Zone');
$this->db->where('Created_Date', '2015-02-23');
$query = $this->db->get('tbl_clients');
if($query->num_rows() > 0)
{
$data = $query->result_array();
foreach($data as $da)
{
$array = "'". $da['Zone'] ."'";
$zone[] = $array;
}
$record = implode(",", $zone);
//echo $record;
$zm_query = $this->db->query("SELECT `ID`, `Name`, `Zone` FROM `tbl_members` WHERE `Zone` IN (".$record.") AND `Sort_Order` = '4' AND `Created_Date` = '".date('Y-m-d', time())."'");
echo "<pre>";
print_r($zm_query->result_array());
echo "</pre>";
}
}
答案 0 :(得分:0)
尝试此查询
select *,count(aa.id) as count tbl_client as aa
join tbl_members as bb on bb.id=aa.member_id
where aa.created_date=date('Y-m-d', time())
group by aa.created_date