-1

i have used this model before and it used to work and now i don't know why $this->db->distinct(); isn't working.

 if($this->input->post('Status'))
    {                                                           
        $this->db->where('Status', $this->input->post('Status'));
    }
     if($this->input->post('PlateNo'))
    {                                                           
        $this->db->like('PlateNo', $this->input->post('PlateNo'));
    }
    if($this->input->post('user.userId'))
    {                                                           
        $this->db->like('user.userId', $this->input->post('user.userId'));
    }

    $this->db->select('*');
    $this->db->distinct();
    $this->db->from($this->table);

    $this->db->join('user', 'user.userId = loanapplication.userId', 'left');
    $this->db->join('loanrequest', 'loanrequest.ApplicationNo = loanapplication.ApplicationNo', 'left');
    $this->db->join('loanapproval', 'loanapproval.RequestNo = loanrequest.RequestNo', 'left');
    $this->db->join('collateraldetails', 'collateraldetails.ApplicationNo = loanapplication.ApplicationNo', 'left');
    $this->db->join('paymentdetails', 'paymentdetails.ApplicationNo = loanapplication.ApplicationNo', 'left');
    $this->db->join('loanpayment', 'loanpayment.PaymentId = paymentdetails.PaymentId', 'left');
    $this->db->join('vehicleinformation', 'vehicleinformation.vehicleNo = collateraldetails.vehicleNo', 'left');

enter image description here

Hanthony Tagam
  • 111
  • 3
  • 13

1 Answers1

2

Try this:

$this->db->group_by('name_of_the_column_you_dont_want_repeated');
Rabin Lama Dong
  • 2,422
  • 1
  • 27
  • 33
  • when to use group_by or distinct? what is the difference? – Hanthony Tagam Jul 16 '17 at 12:28
  • 1
    `GROUP BY` lets you use aggregate functions, like `AVG`, `MAX`, `MIN`, `SUM`, and `COUNT`. Other hand `DISTINCT` just removes duplicates. Please refer to this link for more info https://stackoverflow.com/questions/164319/is-there-any-difference-between-group-by-and-distinct – Rabin Lama Dong Jul 16 '17 at 14:28