Here i want to to join this two query results in to one result the first query looks like this
$this->db->select('bills.date as d_date,bill_details.agent_name,
SUM(bill_details.profit) AS total_profit');
$this->db->join('bill_details', 'bill_details.bill_id=bills.id','left');
$this->db->where('DATE(bills.date) >=', $start_date);
$this->db->where('DATE(bills.date) <=', $end_date);
$this->db->group_by('Date(bills.date)');
$this->db->group_by('bills.customerid');
$query1 = $this->db->get('bills')->result();
return $query1;
the result looks like this
Name Date Purchase
Ned 2019-07-26 210.60
the second query looks like this
$this->db->select('assigned_result.date,assigned_result.user_id,SUM(assigned_result.total_price) AS t_price,SUM(assigned_result.total_dc) AS t_dc');
$this->db->where('DATE(assigned_result.date) >=', $start_date);
$this->db->where('DATE(assigned_result.date) <=', $end_date);
$this->db->group_by('assigned_result.user_id');
$query2 = $this->db->get('assigned_result')->result();
the second query result looks like this
Name Date winning
Ned 2019-07-26 120
Now i want to combine the queries like this
Name Date Purchase winning
Ned 2019-07-26 210.60 120
For getting this result i had joined the queries and return like this
$this->db->select('bills.date as d_date,bill_details.agent_name,
SUM(bill_details.profit) AS total_profit,SUM(assigned_result.total_price) AS t_price,SUM(assigned_result.total_dc) AS t_dc');
$this->db->join('bill_details', 'bill_details.bill_id=bills.id','left');
$this->db->join('assigned_result', 'bills.id=assigned_result.bill_no', 'left');
$this->db->where('DATE(bills.date) >=', $start_date);
$this->db->where('DATE(bills.date) <=', $end_date);
$this->db->group_by('Date(bills.date)');
$this->db->group_by('bills.customerid');
$query1 = $this->db->get('bills')->result();
return $query1;
but am getting result like this
Name Date Purchase winning
Ned 2019-07-26 226 160
purchase amount
is getting wrongly.