php - CodeIgniter Where_In select from different table? -
i trying covert query in active record
select  crm_clients.id, crm_clients.`moved_date`, crm_clients.`contractor_id`  dev_pfands.`crm_clients`  crm_clients.`contractor_id` = 11  , ( crm_clients.`status` = 9  or crm_clients.`status` = 8  or crm_clients.`status` = 7 )  , crm_clients.id in  (select   crm_client_cheques.`client_id`  dev_pfands.`crm_client_cheques`)  , crm_clients.`moved_date` between '2014-08-01'  , '2014-11-29 '  , crm_clients.`contractor_id`<>'' group crm_clients.`id   the section i'm having issue
and crm_clients.id in      (select       crm_client_cheques.client_id          dev_pfands.crm_client_cheques) `   i've tried where_in method overtime try include attempt of $this ->db_pfands -> where('crm_client_cheques.client id' ,'id'); hit errors , have no idea how past this.
the original query should return 703 rows , when i've removed part i'm stuck increase 3045 need included. appreciated.
first of have error in code.
$this->db_pfands->where('crm_client_cheques.client id', 'id');   this
$this->db_pfands->where('crm_client_cheques.client_id', 'id');   you have provide right column name , far know database's column name have not contain space.
now think active record query result.
$query = $this->db->select('crm_clients.id, crm_clients.moved_date, crm_clients.contractor_id')                   ->where('moved_date between "2014-08-01" , "2014-11-29"')                   ->where('contractor_id', 'id')                   ->where_in('status', [9,8,7])                   ->from('crm_clients')                   ->join('crm_client_cheques', 'crm_client_cheques.client_id = crm_clients.id')                   ->group_by('id')                   ->get(); $result = $query->result();   may have change couple of names because in different database, believe can it.
Comments
Post a Comment