Welcome Guest, Not a member yet? Register   Sign In
Sub Queries or better way to do this?
#1

I need to take this query:


PHP Code:
    public function get_active_pools() {
        $this->db->where('active''1');
        $query $this->db->get('pools');
        return $query->result();
    


and join it to a second table that is related by an id and then count how many times the id of the first table is listed in the second table. What is my best method of doing this with Query Builder?
Reply
#2

(This post was last modified: 05-18-2016, 04:48 AM by fakhrawy.)

first you need to add join line to be like this
$this->db->join('d_pools_second','d_pools_second.key_id=pools.pl_id');
then return by count like this
return $query->num_rows();
Reply




Theme © iAndrew 2016 - Forum software by © MyBB