是否足以帮助实现这一目标?

时间:2016-11-04 03:43:45

标签: codeigniter

我需要在查询构建中加入四个表

    function get_debtors( ) {

    $this->db->select('invoice.student_id as STUDENT_ID,student.name AS 
                       STUDENT_NAME,section.name  AS CLASS,
                       invoice.description AS DESCRIPTION, 
                       invoice.amount AS TOTAL_AMOUNT, 
                       invoice.amount_owed  AS AMOUNT_OWED, 
                       parent.name AS PARENT_NAME, 
                       parent.email AS PARENT_EMAIL, 
                       parent.phone AS PARENT_PHONE, 
                       parent.address AS PARENT_ADDRESS,  
                       invoice.status AS STATUS');

    $this->db->from('invoice , student , parent , section ');

    $this->db->join('student  ', 'student.student_id = invoice.student_id');

    $this->db->join('parent ', 'parent.parent_id = student.parent_id, 'left'');

    $this->db->join('section  ', 'section.section_id = student.section_id','left');

    $this->db->where('invoice.status', 'debtor'); 

    $query = $this->db->get(); 

1 个答案:

答案 0 :(得分:0)

试试这个。如果仍有任何错误,请在此处发布错误。

{{1}}