Welcome Guest, Not a member yet? Register   Sign In
multiple table select


My model :

return $this->db->query("select a.msisdn , a.status , s.scoring_loan , s.scoring_fee ,  s.status , s.scoring_tenure , s.validity  from accounting a, scoring s where a.msisdn = $msisdn and a.msisdn = s.msisdn;")->result();

I would like to change it to something neat like: 

return $this->db->select('select a.msisdn' , 'a.status , s.scoring_loan' , 's.scoring_fee' ,  's.status ', 's.scoring_tenure ', 's.validity')->from('accounting a', 'scoring s')->where('a.msisdn = s.msisdn')->where('msisdn', $msisdn)->results();

But it doesn't work.  

Is there a way to do multiple select without using join?


(This post was last modified: 04-12-2016, 12:28 AM by Parker1090.)

$this->db->select() doesn't support multiple values, nor an array. You can however just specify them in one string (also remove the word 'select'). In a similar way, from() accepts a string, but can accept an array.

PHP Code:
return $this->db->select('a.msisdn, a.status, s.scoring_loan, s.scoring_fee, s.status, s.scoring_tenure, s.validity')->from('accounting a, scoring s')->where('a.msisdn = s.msisdn')->where('msisdn'$msisdn)->results(); 

Not tested

(This post was last modified: 04-12-2016, 01:36 PM by Wouter60.)

I would prefer the join statement:

PHP Code:
from('accounting a')
join('scoring s','a.msisdn = s.msisdn')

Theme © iAndrew 2016 - Forum software by © MyBB