Welcome Guest, Not a member yet? Register   Sign In
Joining Joined Tables

I am stuck in generating SQL statement for joining tables.

Basically I have 4 tables. And there are 2 tables with foreign key. Table Sequence is connected to Product table and Region Table. And Distribution table is connected to sequence table.

Table Products.

id | product_desc

Table Region.

id | region_desc

Table Sequence.

id | product_id | region_id

Table Distributions

id | sequence_id | sales | distribution_fee

Here's my code

$this->db->join('sequence', 'sequence.id = distributions.sequence_id', 'left');
$this->db->join('sequence', 'sequence.product_id=products.product_no'); //Generates Error
$this->db->join('sequence', 'sequence.region_id=regions.id'); // Generates Error
$query = $this->db->get();
if($query->num_rows() != 0){
   return $query->result_array();
} else {    
  return false;

any help is highly appreciated. Thanks.

Theme © iAndrew 2016 - Forum software by © MyBB