How to JOIN three tables in Codeigniter

后端 未结 6 2275
离开以前
离开以前 2020-12-03 13:55

I\'m using codeigniter framework to develop one music cms. i have 3 tables in mysql database, Currently im working in \"Album\" Table and \"Model, Controller\". i want to SE

6条回答
  •  死守一世寂寞
    2020-12-03 14:23

    public function getdata(){
            $this->db->select('c.country_name as country, s.state_name as state, ct.city_name as city, t.id as id');
            $this->db->from('tblmaster t'); 
            $this->db->join('country c', 't.country=c.country_id');
            $this->db->join('state s', 't.state=s.state_id');
            $this->db->join('city ct', 't.city=ct.city_id');
            $this->db->order_by('t.id','desc');
            $query = $this->db->get();      
            return $query->result();
    }
    

提交回复
热议问题