Code selection

I have two tables in my database that I need to join. 1 table is a table of articles, and the other is a table of collections. I currently have one.

  $this->db->select('*');
  $this->db->from('collecties');
  $this->db->join('artikelen', 'artikelen.collecties_id = collecties.id');

It gives the correct result, but all double fields (collections have a header field, and artikelen have a title field) will become one (it returns the artikelen.title field), and I cannot access a row of another table (collecties.title field).

I select 10 fields from artikelen and only collecties.title from collections.

What is an easy way to do this without replacing

    $this->db->select('*');

with all 10 fields with as.

+2
source share
1 answer

Make sure both tables get the rows in your join, otherwise it will return null. and change the selection as follows:     $this->db->select('artikelen.*,collecties.title as ctitle');

+4
source

All Articles