Codeigniter Unable to join the table properly |
First, if one product belong only for one category, you don't need t_cp_link table. Just add CategoryID column to Product table
You don't need CategoryID in Product Pack table either, if the ProductID is unique already. Now you will have 3 table: Category, Product and ProductPack. the Query should be like this: $this -> db -> select('Category.CategoryID, CategoryName, Product.ProductID, Product.ProductName, Pack.Dosage, Pack.Unit_price, Pack.Selling_price, Pack.Stock'); $this -> db -> from('ProductPack as Pack'); $this->db->join('Product', 'Product.ProductID = Pack.ProductID', 'left'); $this->db->join('Category', 'Category.CategoryID = Product.CategoryID', 'left'); $this->db->order_by("Product.ProductID", "ASC"); $query = $this->db->get(); if ($query -> num_rows() > 0) { return $query -> result_array(); // or result(); } else { return false; } |
Messages In This Thread |
Codeigniter Unable to join the table properly - by apysan - 02-23-2017, 01:11 AM
RE: Codeigniter Unable to join the table properly - by andersonunsonst - 02-23-2017, 07:36 AM
RE: Codeigniter Unable to join the table properly - by AzrielOmega - 02-23-2017, 08:22 PM
|