Multiple Joins in Codeigniter

前端 未结 4 1949
孤独总比滥情好
孤独总比滥情好 2020-12-08 23:33

I\'m new to building databases and I\'m trying to do a JOIN based on a having three database tables.

Table A = ID, Name, etc
Table B = ID, Name, etc
Table C          


        
4条回答
  •  鱼传尺愫
    2020-12-09 00:17

    $this->db->select('*');
    $this->db->from('blogs');
    $this->db->join('comments', 'comments.id = blogs.id');
    $this->db->join('authors', 'authors.id = comments.author_id');
    

    hopefully you get my example.

    Just add another $this->db->join();

    For complex queries you might be better off looking at an ORM such as doctrine

提交回复
热议问题