如何在codeigniter中使用distinct

时间:2017-07-16 07:28:39

标签: codeigniter datatables

我之前使用过这个模型并且它曾经工作过,现在我不知道为什么$ this-> db-> distinct();没有工作。

 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

1 个答案:

答案 0 :(得分:2)

试试这个:

$this->db->group_by('name_of_the_column_you_dont_want_repeated');
相关问题