Welcome Guest, Not a member yet? Register   Sign In
codeigniter join
#2

$person_interest = "( SELECT pi.person_id, pi.payment_id, pi.person_interest_id, pi.paid_interest FROM person_interest as pi JOIN payment as p ON p.payment_id = pi.payment_id WHERE pi.status = 'active' AND p.mode = 'Payin' AND p.customer_type = 'P' GROUP BY p.customer_id  )";

$this->db->select( 'payment.*, SUM( COALESCE( payment.amount ) ) AS amount, P.name, PI.paid_interest, B.branch_name' );

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

$this->db->where( 'payment.type', $mode_type );
$this->db->where( 'payment.mode', $mode );

$branch_id = $this->session->userdata( 'branch_id' );

$this->db->where( 'payment.branch_id', $branch_id );

$this->db->join( 'people as P', "P.id = payment.customer_id AND (payment.customer_type = 'P' or payment.customer_type = 'CP' OR payment.customer_type = 'LP' OR payment.customer_type = 'BP' OR payment.customer_type = 'TS' )", 'left' );
$this->db->join( $person_interest . ' AS PI', 'PI.payment_id = payment.payment_id', 'left' );
$this->db->join( 'branch AS B', 'B.id = payment.branch_id', 'left' );
$this->db->group_by( 'payment.customer_id' );
$query  = $this->db->get( 'payment' );




i found solution , this worked for me perfectly
Reply


Messages In This Thread
codeigniter join - by durairaj - 02-23-2021, 12:38 AM
RE: codeigniter join - by durairaj - 02-23-2021, 04:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB