0

I am having difficulty JOINing 3 tables.

I have following table (Column)

apk_inv_item (item_id)

apk_inv_category (category_id)

apk_inv_item_category_defination (item_id, category_id)

I want to get category ID of the Item from the Item to Category Mapping table.

Here is what I have tried so far.. But it

select("apk_inv_item.*, apk_inv_category.inv_category_id")
->join("apk_inv_category", "apk_inv_item_category_defination.inv_category_id
 = apk_inv_category.inv_category_id")
->find_all();

But I get Call to a member function num_rows() that means query is not right.(Please note that I have tried simple 2 table JOIN with another table for testing and it works, means there is no issue with my MySQL connection or PHP code. Its issue with building that query)

Umair Ayub
  • 19,358
  • 14
  • 72
  • 146

1 Answers1

-1

Try this ..

  $this->db->select('*');
    $this->db->from('apk_inv_item');
    $this->db->join('apk_inv_category', 'apk_inv_category.category_id= apk_inv_item_category_defination.category_id');
    $this->db->join('apk_inv_item_category_defination', 'apk_inv_item_category_defination.item_id = apk_inv_item.item_id');


    $count = $this->db->count_all_results();

    return $count;

Hope its helps.

hassan
  • 145
  • 2
  • 16